Page 1 of 1
montage does not seem to honor "-strip"
Posted: 2015-12-31T15:07:23-07:00
by sas
Even with the "-strip" option, "montage" outputs a PNG with a redundant gAMA chunk:
Code: Select all
$ montage rose: -strip PNG:- | identify -verbose - | grep 'png:'
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:gAMA: gamma=0.45454544 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 128, 126
png:sRGB: intent=0 (Perceptual Intent)
"convert" on the other hand, does
not output the redundant gAMA chunk when the "-strip" option is used:
Code: Select all
$ convert rose: -strip PNG:- | identify -verbose - | grep 'png:'
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 70, 46
png:sRGB: intent=0 (Perceptual Intent)
How can I get montage to respect "-strip" just like convert does?
Re: montage does not seem to honor "-strip"
Posted: 2015-12-31T15:19:13-07:00
by fmw42
Pipe your montage output to convert and do the strip there
Re: montage does not seem to honor "-strip"
Posted: 2016-01-01T09:35:53-07:00
by sas
That works, thanks.
But why does "montage -strip" not do it it in the first place? Is it a bug? The
montage option summary does list -strip as a supported option.
Re: montage does not seem to honor "-strip"
Posted: 2016-01-01T10:21:16-07:00
by fmw42
I do not know. But why do you think the gamma chuck in redundant? Does it hurt to keep it? I would think it best to have that there so that PNG readers will know what gamma it has.
Re: montage does not seem to honor "-strip"
Posted: 2016-01-01T12:24:46-07:00
by glennrp
The gAMA chunk is redundant when the sRGB chunk is present.
-strip should also be removing the cHRM chunk. I'll see about fixing that.
The documentation says about the -strip option:
strip the image of any profiles or comments.
It's debatable whether the PNG gAMA, cHRM, and sRGB chunks are profiles. I think they are,
and -strip should be removing them all. The fix is to add gAMA and cHRM to the list of chunks in
magick/image.c" line 3514
Re: montage does not seem to honor "-strip"
Posted: 2016-01-01T13:08:32-07:00
by sas
fmw42 wrote:why do you think the gamma chuck in redundant?
Like the
"-define" documentation says:
"
As a special case, if the sRGB chunk is excluded and the gAMA chunk is included, the gAMA chunk will only be written if gamma is not 1/2.2, since most decoders assume sRGB and gamma=1/2.2 when no colorspace information is included in the PNG file.
[...]
The -strip option does the equivalent of the following for PNG output:
-define png:exclude-chunk=EXIF,iCCP,iTXt,sRGB,tEXt,zCCP,zTXt,date"
That is, stripping a gAMA of 0.45454544 should be fine because well-behaved PNG readers will assume it's sRGB anyway.
fmw42 wrote:Does it hurt to keep it? I would think it best to have that there so that PNG readers will know what gamma it has.
It depends on where the images will be used. In my case, they'll be part of a website.
And the problem is that modern browsers like Firefox are
not well-behaved in the aforementioned sense: They display the colors of PNGs with a 0.45454544 gAMA chunk
differently from everything else - where everything else includes colors from CSS style sheets, or stripped PNGs, or from other image formats, etc.
So one is better off stripping 0.45454544 gAMA chunks from PNGs that will be part of a website, so that any #rrggbb color in the image looks identical to the same #rrggbb color in surrounding page elements. The color may look "wrong" (i.e. not properly color-corrected), but at least this way all page elements will be rendered
equally wrong.
Re: montage does not seem to honor "-strip"
Posted: 2016-01-01T13:31:59-07:00
by fmw42
Thanks for the explanation. The IM developers will need to look into this. You can post a note to the Bugs forum with a link back here to your post above. Please include your IM version and platform.
Re: montage does not seem to honor "-strip"
Posted: 2016-01-01T13:39:57-07:00
by fmw42
This seems to work on IM 6.9.2.10 Q16 Mac OSX
Code: Select all
montage rose: -define png:exclude-chunk=gAMA -tile 1x1 -geometry +0+0 rose.png
identify -verbose rose.png
Code: Select all
Properties:
date:create: 2016-01-01T12:37:48-08:00
date:modify: 2016-01-01T12:37:48-08:00
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 70, 46
png:sRGB: intent=0 (Perceptual Intent)
signature: a698f2fe0c6c31f83d19554a6ec02bac79c961dd9a87e7ed217752e75eb615d7
see define at
http://www.imagemagick.org/script/comma ... php#define