improper image header

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
vasdeep
Posts: 4
Joined: 2018-04-14T19:39:57-07:00
Authentication code: 1152

improper image header

Post by vasdeep » 2018-04-14T20:14:12-07:00

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!
Last edited by vasdeep on 2018-04-14T22:36:55-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 24122
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: improper image header

Post by fmw42 » 2018-04-14T22:05:28-07:00

I moved this topic here since the Consulting forum is for Paid consulting only

vasdeep
Posts: 4
Joined: 2018-04-14T19:39:57-07:00
Authentication code: 1152

Re: improper image header

Post by vasdeep » 2018-04-16T22:13:01-07:00

Did anyone get chance to look at this?

Please let me know.
Last edited by vasdeep on 2018-04-17T09:14:46-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 24122
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: improper image header

Post by fmw42 » 2018-04-16T22:36:14-07:00

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?

vasdeep
Posts: 4
Joined: 2018-04-14T19:39:57-07:00
Authentication code: 1152

Re: improper image header

Post by vasdeep » 2018-04-16T22:53:59-07:00

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:-

snibgo
Posts: 10954
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: improper image header

Post by snibgo » 2018-04-17T00:58:07-07:00

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".
snibgo's IM pages: im.snibgo.com

vasdeep
Posts: 4
Joined: 2018-04-14T19:39:57-07:00
Authentication code: 1152

Re: improper image header

Post by vasdeep » 2018-04-17T09:14:29-07:00

Thanks for your help!

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

Post Reply