Question about the operation sequence

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
hanselda

Question about the operation sequence

Post by hanselda »

Does anyone know how to influence the sequence of the operations applied to a image? For example:

convert a.jpg -opt1 -opt2 -opt3 b.jpg

What is the sequence of the operations? It seems that in imagemagick there is some internal priority of the operations. For example:

convert a.jpg -crop 10x10+2+2 -rotate 90 b.jpg

Here the rotation is always applied before cropping. How can one influence the operation sequence in this case?

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

Re: Question about the operation sequence

Post by fmw42 »

You will get a different result if you do

convert a.jpg -rotate -crop 10x10+2+2 b.jpg

also keep in mind you need to add +repage when doing -crop to get rid of the virtual canvas

Not all options are order dependent, though.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Question about the operation sequence

Post by anthony »

What is your IM version number????

Im version 5 had a problem in that multiple options would be stored and executed in an internal priority.

IM version 6 was developed with the idea of doing all options IN THE ORDER GIVEN!

See http://imagemagick.org/Usage/basics/ for details.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
hanselda

Re: Question about the operation sequence

Post by hanselda »

Well that is right. I made a mistake:

If I do

Code: Select all

convert a.jpg -crop 10x10+2+2 -rotate 90 b.jpg
, the crop is applied before rotation, i.e. the right sequence. But if I do

Code: Select all

convert -crop 10x10+2+2 -rotate 90 a.jpg b.jpg
, the crop is applied after rotation.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Question about the operation sequence

Post by Bonzo »

Anything after version 6 you are supposed to read in the image first so:
This is correct:

Code: Select all

convert a.jpg -crop 10x10+2+2 -rotate 90 b.jpg
This is incorrect

Code: Select all

convert -crop 10x10+2+2 -rotate 90 a.jpg b.jpg
Post Reply