Page 1 of 1

-write .png = unexpected

Posted: 2010-12-20T13:12:54-07:00
by GreenKoopa
Inserting a "-write b.png" into my command alters the working colorspace for subsequent operations. Is this a bug? Writing out to a .tif doesn't do this, so that's my work-around. A contrived but simple example:

Code: Select all

ImageMagick 6.6.6-5 2010-12-12 Q16

> convert -size 10x300 gradient:red-blue -colorspace Lab -write miff:a -write b.png -write miff:c null:

> convert a -format "%r %[colorspace]" info:
DirectClassLab Lab

> convert b.png -format "%r %[colorspace]" info:
DirectClassRGB RGB

> convert c -format "%r %[colorspace]" info:
DirectClassRGB RGB

Re: -write .png = unexpected

Posted: 2010-12-20T19:48:27-07:00
by anthony
MIFF can handle a LAB colorspace. PNG is limited to purely RGB colorspace!!!!!

You can force it to save LAB values in a PG image by setiing -set colorspace RGB
BUt PNG will not know (and can't record) that the values stored are actually in LAB colorspace.

Re: -write .png = unexpected

Posted: 2010-12-20T19:51:14-07:00
by anthony
Any particular reason you want to save in LAB colorspace?

Re: -write .png = unexpected

Posted: 2010-12-21T00:10:59-07:00
by GreenKoopa
+write helped here.
anthony wrote:Any particular reason you want to save in LAB colorspace?
I was trying out a lightness adjustment. It worked well for one, HSB looked better for the other. -distort SRT made a mess of edges in Lab. Going from RGB to Lab gave slightly different results than Photoshop, but -set colorspace sRGB generated results way different. I was troubleshooting inserting -write everywhere. I never did corner it, but something seemed off. Between this and curves, and hurried for the holidays, I gave up and Photoshopped the six images. I hoped to help out with another bug, but I'm feeling more frustrated and tired than helpful today. :(

Re: -write .png = unexpected

Posted: 2010-12-22T05:50:21-07:00
by glennrp
GreenKoopa wrote:Inserting a "-write b.png" into my command alters the working colorspace for subsequent operations.
In 6.6.6-7 beta, the PNG encoder makes a clone of the image before modifying it. The original image is left intact for further operations.

Re: -write .png = unexpected

Posted: 2010-12-22T06:27:42-07:00
by magick
Use +write rather than -write. The +write option ensures there are no image side effects in your work flow.

Re: -write .png = unexpected

Posted: 2010-12-22T16:52:21-07:00
by anthony
Magick, what sort of side effects? Colorspace change? Color Quantization and Dither?
Anything else?

Re: -write .png = unexpected

Posted: 2010-12-22T17:36:17-07:00
by magick
The side effects depends on the image format. Gif for example color reduces any image with more than 256 unique colors.

Re: -write .png = unexpected

Posted: 2010-12-22T18:31:03-07:00
by anthony
I sort of figured, but I just wanted it to be clear.

I'll include that note in IM Examples, File Handling, Saving Images.
http://www.imagemagick.org/Usage/files/#write