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

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
spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

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

Post 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?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post 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 :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Looks like that page has now been updated. Thanks Chrisy.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply