ImageMagick: geometry does not contain image

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
xinito

ImageMagick: geometry does not contain image

Post by xinito »

I have an image, which looks fine to me when I write it out.

I use image.crop(Geometry) to crop the image, but it gives me the exception: ImageMagick: geometry does not contain image.

The image was previously cropped without error. The error occured when I crop the cropped image.

I print out the size od the first cropped image and the geometry for the second crop, they all look reasonable to me.

Please help.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Cropping is relative to the virtual canvas. Try setting the page (which defines the virtual canvas) to 0x0+0+0 before you attempt a second crop.
xinito

Post by xinito »

Thank you very much. May I ask which C++ API method shall I use to set the virtual canvas?
xinito

Post by xinito »

use "page", i think
xtonic

Re: ImageMagick: geometry does not contain image

Post by xtonic »

What else i might try here with the same error while trying to Crop image ? setting page 0x0+0+0 does not help :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick: geometry does not contain image

Post by fmw42 »

xtonic wrote:What else i might try here with the same error while trying to Crop image ? setting page 0x0+0+0 does not help :(
0x0 makes the result of zero size whatever, so no doubt it complains. you need to specify a WIDTHxHEIGHT+0+0 where the width and height are the size of your image

Sorry I don't know any APIs, just command line.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagick: geometry does not contain image

Post by anthony »

fmw42 wrote:
xtonic wrote:What else i might try here with the same error while trying to Crop image ? setting page 0x0+0+0 does not help :(
0x0 makes the result of zero size whatever, so no doubt it complains. you need to specify a WIDTHxHEIGHT+0+0 where the width and height are the size of your image

Sorry I don't know any APIs, just command line.

Sorry Fred. A page size of 0x0 means it is unset (as it is nonsense). It means use the size of the actual image!

If after setting the page for an image your crop is still failing then the crop bounds do not actually hit the image proper! The offset and size specifing the area to crop just 'misses' the image.

See IM Examples, The Missed Image (from a bad crop)
http://www.imagemagick.org/Usage/crop/#crop_missed

This especially happens if you did not use +repage after previous crops or image trimming, before saving the result. OR you are working with GIF animations.



If you will like further help, we will need an example, and the command you are trying, so we can see what is wrong, but I can pretty well gurantee it is as we have said. your crop 'missed' the actual image proper.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply