Issues with Multiple "convert -extract wxh+x+y"

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
hasso
Posts: 7
Joined: 2012-02-29T14:21:06-07:00
Authentication code: 8675308

Issues with Multiple "convert -extract wxh+x+y"

Post by hasso »

version 6.7.5-7 on Linux Mint 10

My program extracts a portion of an image using "convert -extract wxh+x+y input.tif interim.tif" syntax, and that gives me the results I am looking for. However, when I subsequently want to extract a portion of interim.tif using the same syntax "convert -extract wxh+x+y interim.tif output.tif", it does not give me the expected results. It either gives me an unexpected output.tif (different location or different size) or doesn't find anything. I think that my program is correct because if I open the interim.tif in GIMP and then resave it as interim.tif, I do get the expected output.tif results. So it looks like ImageMagick must be using some sort of saved property when doing "convert -extract" conversions? Can anyone confirm how I should be doing multiple "convert -extract" conversions (input.tif->convert/extract->interim.tif->convert/extract->output.tif)?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Issues with Multiple "convert -extract wxh+x+y"

Post by anthony »

Why use -extract?

Use -crop

Code: Select all

  convert input_image -crop WxH+X+Y +repage  -crop WxH+X+Y +repage  save_image
The +repage is important as crop (and probably extract) preserves the virtual canvas (where the image was cropped from).

ASIDE: IMv7 will likely see -crop automatically do a +repage, while +crop (layers crop) does not, for ALL crop operations.
IMv6 +crop just does the same thing as the current -crop
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
hasso
Posts: 7
Joined: 2012-02-29T14:21:06-07:00
Authentication code: 8675308

Re: Issues with Multiple "convert -extract wxh+x+y"

Post by hasso »

OK.. I'll give -crop a try and report back. Although I omitted it in my post, I did have a +repage in my "convert -extract" syntax so would have expected it to work.
Post Reply