Page 1 of 1

improper image header

Posted: 2018-04-14T20:14:12-07:00
by vasdeep
Hi,

I am running on Mac OS High Sierra

The following commands work fine with ImageMagick 6.9.0

convert -define stream:buffer-size=0 png:- png:- -alpha off -compose copy-opacity -composite png:-
compare -define stream:buffer-size=0 -fuzz 17% -metric AE png:- png:- png:-

I updated ImageMagick 6.9.0 to ImageMagick 7.0.7-28 then both of these commands started failing with the below error messages

magick -define stream:buffer-size=0 png:- png:- -alpha off -compose copy-opacity -composite png:-
magick: improper image header `/var/folders/tb/11n2czg57ts9dzxypdsmlqk99c46m9/T/magick-26635byT1dtHsAuT3' @ error/png.c/ReadPNGImage/4231.

magick compare -define stream:buffer-size=0 -fuzz 17% -metric AE png:- png:- png:-
For input string: "compare: improper image header `/var/folders/tb/11n2czg57ts9dzxypdsmlqk99c46m9/T/magick-26363xwcFdjrv3CT0' @ error/png.c/ReadPNGImage/4231."

Can you please guide me what I have to change in those commands?

If I store png files in a temporary folder and run the above commands by replacing png:- with temporary file path then both the commands run fine. But I want the commands to work with InputStream.

Thanks in advance!

Re: improper image header

Posted: 2018-04-14T22:05:28-07:00
by fmw42
I moved this topic here since the Consulting forum is for Paid consulting only

Re: improper image header

Posted: 2018-04-16T22:13:01-07:00
by vasdeep
Did anyone get chance to look at this?

Please let me know.

Re: improper image header

Posted: 2018-04-16T22:36:14-07:00
by fmw42
IM 6 used convert not magick. I do not understand the use of png:- png:- in you command. Have you tried the commands with actual image files directly rather than some kind of stdin/stdout?

Re: improper image header

Posted: 2018-04-16T22:53:59-07:00
by vasdeep
Thanks for the reply!
I used convert command in IM 6 but now I updated to IM 7 so I changed commands to magick. Yes the commands with actual image files directly work fine!

These were my IM 6 commands and they were working fine before upgrading to IM 7

convert -define stream:buffer-size=0 png:- png:- -alpha off -compose copy-opacity -composite png:-
compare -define stream:buffer-size=0 -fuzz 17% -metric AE png:- png:- png:-

In IM 7, I changed the commands as below but they started throwing "Improper image header" error.

magick -define stream:buffer-size=0 png:- png:- -alpha off -compose copy-opacity -composite png:-
magick compare -define stream:buffer-size=0 -fuzz 17% -metric AE png:- png:- png:-

Re: improper image header

Posted: 2018-04-17T00:58:07-07:00
by snibgo
vasdeep wrote:Here is the GitHub project to reproduce the issue easily (JUnit test):
There's a load of stuff on there. Can you show the problem in a single command?

Using "png:-" as an input means that something must be writing, perhaps to a pipe so that magick reads it from stdin, like this:

Code: Select all

%IM%convert rose: png:- |%IMG7%magick -define stream:buffer-size=0 png:- info:
png:- PNG 70x46 70x46+0+0 8-bit sRGB 6975B 0.016u 0:00.014
This works fine, but reading from "png:-" twice doesn't work because the entire stream is consumed by the first "png:-". The second "png:-" fails because there is no data, and IM reports this as "improper image header".

Re: improper image header

Posted: 2018-04-17T09:14:29-07:00
by vasdeep
Thanks for your help!

It works fine after converting the pngs to MIFF.
https://stackoverflow.com/questions/498 ... gick-7-0-7