Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Improper Image header #579

Closed
santoshshetty2612 opened this issue Jul 17, 2017 · 10 comments
Closed

Error: Improper Image header #579

santoshshetty2612 opened this issue Jul 17, 2017 · 10 comments
Labels

Comments

@santoshshetty2612
Copy link

santoshshetty2612 commented Jul 17, 2017

I am using image magick to label my application icon through fastlane.
But my build randomly fails because of the below error. Sometimes it works fine and fails on other occassions. I am running the build on Jenkins on a Mac machine.

[03:09:38]: �[31mfastlane finished with errors�[0m
�[31m
[!] Something went wrong while running badge: identify /var/folders/fc/lp0tsgx51_ldd7m_v7_zqnc800007q/T/mini_magick20170717-56250-alhq3a.png failed with error:
identify: improper image header `/var/folders/fc/lp0tsgx51_ldd7m_v7_zqnc800007q/T/mini_magick20170717-56250-alhq3a.png' @ error/png.c/ReadPNGImage/3933.
�[0m

@santoshshetty2612 santoshshetty2612 changed the title Improper Image header Error: Improper Image header Jul 18, 2017
@mikayla-grace
Copy link

One possible solution, ensure you are a recent release of ImageMagick. Another is that the image file is corrupt. Post a URL to your image here so we can download it and inspect it for corruption.

@wolfe719
Copy link

I get the same intermittent failure with image magick - and am using:

Version: ImageMagick 7.0.6-0 Q16 x86_64 2017-06-12 http://www.imagemagick.org

I will try updating to the latest version (7.0.6.7), and see if that makes a difference.

Oops - homebrew only has up to v7.0.6.6. I will try with that version first. But upgrading imagemagick also upgraded a lot of other libraries for me (jpeg, libpng, libtiff). Maybe one of those was returning a bogus, intermittent error?

@wolfe719
Copy link

No, that was not the issue.

I use Fastlane to call the badge function, which uses a mini_magick gem (v4.5.1) to add two badges at the top of the application icons. This combination works most of the time (9 out of 10 times?)

Sometimes, though, the combination produces a failure in parsing what looks like an intermediate PNG. My latest theory is that some combination of the mini_magick gem (v4.5.1) and the badge gem (v0.8.4) might be trying to start a subsequent operation before a previous operation completes?

Here is the rather cryptic and less than totally helpful error message I get:

Something went wrong while running badge: identify /var/folders/57/dhl6f07524q0ygmthfjz4n1h0000gn/T/mini_magick20170812-34515-gelu3n.png failed with error:
identify: improper image header `/var/folders/57/dhl6f07524q0ygmthfjz4n1h0000gn/T/mini_magick20170812-34515-gelu3n.png' @ error/png.c/ReadPNGImage/4232.

Does anyone have any ideas what might be going wrong?

@glennrp
Copy link
Contributor

glennrp commented Aug 13, 2017

Here is line 4232 of coders/png.c from IM-7.0.6-7:

if (count < 8 || memcmp(magic_number,"\211PNG\r\n\032\n",8) != 0)
    ThrowReaderException(CorruptImageError,"ImproperImageHeader");

So it's saying the PNG magic number (the first 8 bytes of the PNG file) were
corrupted.

Can you upload that intermediate PNG image (/var/folders/57/dhl6f07524q0ygmthfjz4n1h0000gn/T/mini_magick20170812-34515-gelu3n.png in this run, some other name in var/folders/* each time
you try) to some free image uploading service so we can have a look? Or alternatively,
just run "xxd [...file.png] | head" and post the result of that here?

@wolfe719
Copy link

Here is the initial image's header information:

00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
00000010: 0000 001d 0000 001d 0806 0000 0056 9367  .............V.g
00000020: 0f00 0004 0d69 4343 5049 4343 2050 726f  .....iCCPICC Pro
00000030: 6669 6c65 0000 388d 8d55 5d68 1c55 143e  file..8..U]h.U.>
00000040: bb73 6723 24ce 536c 3485 74a8 3f0d 250d  .sg#$.Sl4.t.?.%.
00000050: 9356 34a1 b4ba 7fdd dd36 6e96 4936 da22  .V4......6n.I6."
00000060: e864 f6ee ce98 c9ce 3833 bbfd a14f 4550  .d......83...OEP
00000070: 7c31 ea9b 14c4 bfb7 8020 28f5 0fdb 3eb4  |1....... (...>.
00000080: 2f95 0a25 dad4 2028 3eb4 f883 50e8 8ba6  /..%.. (>...P...
00000090: eb99 3b33 9969 bab1 de65 ee7c f39d ef9e  ..;3.i...e.|....

I am not certain how to get the intermediate file's header, since the files are deleted after an unsuccessful run. I keep trying to put a byebug immediately after the badge command -- but now it refuses to fail for me. SIGH. I will keep trying!

@santoshshetty2612
Copy link
Author

For me this error is quite frequent while using with fastlane.

Earlier I never faced this issue but recently its quite frequent. I am using the attached image for badging.

The image is picked from the temp location and it throws the error.

improper image header `/var/folders/fc/lp0tsgx51_ldd7m_v7_zqnc800007q/T/mini_magick20170817-65853-6zr79y.png' @ error/png.c/ReadPNGImage/3933.
�[0m

alpha

@reallyseth
Copy link

I also call badge from fast lane, and I've been seeing this error too, sporadically though. My build server logs just showed me the error, but when I re-ran the command through the command line, everything worked fine.

@wolfe719
Copy link

Badge Green just got updated to fix this issue.

Seems that the server used for generating badges sometimes just returns am error. Badge Gem was packaging that text into a JPG file, ignoring the return code. Then Badge was sending that text-instead-of-image file to imagemagick, which was throwing the exception.

@santoshshetty2612
Copy link
Author

@wolfe719 Is this fix live?
I am still facing this issue but the frequency is much less now.

@santoshshetty2612
Copy link
Author

I am not facing any issues with the badge. But I changed the way I am using badge.
Earlier I was using badge directly. But since I am using faslane, now I am using the badge through the plugin.

https://github.com/HazAT/fastlane-plugin-badge

If you are using fastlane, then please use the above plugin for things to work without any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

6 participants