yasirkula / UnityNativeGallery

A native Unity plugin to interact with Gallery/Photos on Android & iOS (save and/or load images/videos)
MIT License
1.4k stars 199 forks source link

An error saying missing IHDR occurs. #297

Open ParkEunSeong opened 1 year ago

ParkEunSeong commented 1 year ago

Description of the bug

This nativegallery occurs in native gallery. Please tell me how to solve it.

Reproduction steps

If possible, providing reproduction steps would be very helpful while pinpointing the issue. You can also post screenshots if you think they would be helpful.

Platform specs

Please provide the following info if this is a Unity 3D repository.

Additional info

Please check Logcat (Android) or Xcode console (iOS) for any meaningful error messages and include them here.

libpng error: [00][00][00][00]: missing IHDR Couldn't load image at path: /var/mobile/Containers/Data/Application/D06113B1-A048-46B9-A0C0-825C3AFFA123/Library/Caches/tmpImg NativeGallery:LoadImageAtPath(String, Int32, Boolean, Boolean, Boolean)

yasirkula commented 1 year ago

In this thread, the plugin seemed to not have this issue in a new Unity project. Is it the same for you?

ParkEunSeong commented 1 year ago

In this thread, the plugin seemed to not have this issue in a new Unity project. Is it the same for you?

That's right. It works normally in a newly created project. I overwrote the plugin that works normally, but the same thing happens. If you look at the log, the difference is that even the file name is written in the log when it works normally, but in projects that don't work, the folder called tmpImg ends. Do you also know what missing IHDR means?

yasirkula commented 1 year ago

The error occurs at this line, right?

https://github.com/yasirkula/UnityNativeGallery/blob/c777ed2b916eed860bbab7dc9baf2bc422ec42ce/Plugins/NativeGallery/NativeGallery.cs#L795

And does replacing this filename to tmpImg.png make any difference:

https://github.com/yasirkula/UnityNativeGallery/blob/c777ed2b916eed860bbab7dc9baf2bc422ec42ce/Plugins/NativeGallery/NativeGallery.cs#L145

Lastly, could you put numerous NSLog functions inside this function and see if both your current project and the empty project follow exactly the same codepath (enter the same if conditions, return the same filepath, etc.) while picking the same png image?

https://github.com/yasirkula/UnityNativeGallery/blob/c777ed2b916eed860bbab7dc9baf2bc422ec42ce/Plugins/NativeGallery/iOS/NativeGallery.mm#L703

ParkEunSeong commented 1 year ago

libpng error: [00][00][00][00]: missing IHDR Couldn't load image at path: /var/mobile/Containers/Data/Application/A6A4723A-5627-48E6-B2A0-BC42DDB12123/Library/Caches/pickedMedia1.png

Log with maxsize set to -1. While there are images that can be imported, there are images that cannot be imported.

yasirkula commented 1 year ago

May I ask what you did differently in your latest post and the original post? Can you follow my guide here: https://github.com/yasirkula/UnityNativeGallery/issues/297#issuecomment-1723080366

ParkEunSeong commented 12 months ago

May I ask what you did differently in your latest post and the original post? Can you follow my guide here: #297 (comment)

hello. We found out the cause. Images captured by iOS or saved from a camera are in .HEIC format. After converting the .HEIC format photo to .JPG, I loaded the image normally using Native Gallery Load. Is it possible to update the library to convert .heic format to .jpg or .png?

yasirkula commented 12 months ago

But the same HEIC image can be loaded in an empty project correctly, according to your reply. I can't find the difference between the empty project and the actual project unless you help me.