Invalid PNG Image file: iDOT doesn't point to valid IDAT chunk

房东的猫 提交于 2019-12-09 08:41:02

问题


I have some HTML content pages in an app and I'm using a UIWebView to display them. Some of these pages have a PNG image in them that is generating the following message in the debug console in xcode:

ImageIO: PNG invalid PNG file: iDOT doesn't point to valid IDAT chunk

The image still displays and looks correct. Also this only happens when I run the app on an iPad (3rd generation). My iPhone 4 doesn't display this message.

My first thought was that it was caused by a ~ character in the filename (I've added the ~ipad tag to the filename). However, removing the ~ character doesn't have any effect.

I've done a google search but I only get 3 results. 2 of them are in Chinese that doesn't seem to be translated well by Google's translater. The other results seems to be someone with the same issue as me, but no responses to his post.


回答1:


Had the same problem. Solution: use "color sync utility" which is a standard program, you can load from launchpad. Open the png file and save it with the utility.




回答2:


'cleaning' the project (xcode menu path : product -> clean) solved this exact issue for me.

Resaving the .png with a new name did not.

Image did appear in the simulator but not on the test device (ipod touch 5th gen.)

Very large image 4000 x 4000




回答3:


Strangely, I had the exact same issue just about an hour ago. I didn't find a particular reason for why it was failing, but I think I was able to "fix" the image to make it display properly and not throw an error.

I just opened it in Preview and exported a new PNG file from the source. Once I replaced the bad image in my project file with the newly created one, I cleaned, compiled and it worked as expected.

Hope it's as easy as that for you...




回答4:


You may want to check you don't have another file with the same name in another directory. That is what caused this error for me .. (duplicate Default.png)




回答5:


I had the same problem with my app.It turn out that the images that the user was uploading to my server and edited with php +imagemagik where striped out.I was using the following command to edit the uploaded image:

convert $uploadfile -resize 300x300 -quality 30 -strip $uploadfile

When i removed the -strip parameter the error was disappeared !




回答6:


Same problem here.
1 - Close XCode;
2 - Open the image in Photoshop;
3 - Re-save ( replace the same image ) with 80% quality;
4 - Open XCode, clean it CMD + SHIFT + K;
5 - Build it in your device again;

Very simple and work for me.
And for you ?



来源:https://stackoverflow.com/questions/12007717/invalid-png-image-file-idot-doesnt-point-to-valid-idat-chunk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!