Page 1 of 1

monochrome, resample, and compress - why does order matter?

Posted: 2006-08-18T12:37:44-07:00
by spieler
I have a monochrome tiff that I want to resample to a lower resolution.

If I do "convert a.tif -resample 100x100 -monochrome -compress group4" it works as I expect producing a monochrome tiff with group4 compression.

If I do "convert a.tif -monochrome -compress group4 -resample 100x100" it produces a 250+ color tiff with RLE compression. The results are the same for "convert -monochrome -compress group4 a.tif -resample 100x100".

I just read through the command line processing page, and do not see any caveats about ordering other than the types (settings, operators, etc.).

The only thing I can think of is that it does it in the order received. If it resamples last, that would explain why the monochrome and compression isn't sticking. Although in the documentation, it says of those two "An image setting stays in effect until it is reset or the command line terminates" which does not appear to be happening.

Can anyone explain this better or can I consider this a bug?

Posted: 2006-08-21T20:08:49-07:00
by anthony
See IM CommandLine Basics
http://www.cit.gu.edu.au/~anthony/graph ... k6/basics/

As of IM v6 (and the reson for the major version change) Im processes all options in command line order. Settings get set, and operators are applied as they are seen.

resampling and image before and after -monochrome will naturally produce VERY different results. Both are operators and are applied immediately they are seen on the command line.

-compress is a setting and is only used by the image save at the end, so it doesn't matter when it is seen, as long as it is before the final save for it to be used :-)

Posted: 2006-08-23T08:27:53-07:00
by spieler
First, Anthony, thanks for your web page (which I've referenced numerous times) and for all your posts on the forum.

In the documentation at http://www.imagemagick.org/script/comma ... hp#setting it says that -monochrom is a setting. If this is an operator as you say it is and as I see in practice, then the documentation just needs to be updated to reflect this.

Posted: 2006-08-23T20:24:36-07:00
by anthony
Looks like that page has now been updated. Thanks Chrisy.