Page 1 of 2

unexpected error "convert: geometry does not contain image"

Posted: 2009-05-12T12:39:36-07:00
by alex_nb
Hello,
trying to execute a command like this:

convert res.jpg '-crop' '100x235+200+102' '-resize' '300x705!' '-crop' '300x300+0+0' test.jpg

I get the error:
convert: geometry does not contain image `res.jpg' @ transform.c/CropImage/507.

but I think it's a bug, in fact if I issue the command in two phases, for example:
convert res.jpg '-crop' '100x235+200+102' '-resize' '300x705!' tmp.jpg
convert tmp.jpg '-crop' '300x300+0+0' test.jpg
everything works fine

Did I miss something?

Re: unexpected error "convert: geometry does not contain image"

Posted: 2009-05-12T13:10:00-07:00
by magick
Add +repage to your command line. Does that fix the problem?

Re: unexpected error "convert: geometry does not contain image"

Posted: 2009-05-13T00:01:33-07:00
by alex_nb
Hello and thanks for your answer, that seems to fix the problem.

Anyway I can't understand why I should use it explicitly, shouldn't it be automatic?

Since the commandline is automatically generated I added a +repage before every operation, it seems to work fine but do you think that could cause any kind of problems?

Thanks,
Alex

Re: unexpected error "convert: geometry does not contain image"

Posted: 2009-05-13T17:09:05-07:00
by anthony
If it was automatic, then you lose information that is vital to many other image processing tasks. Especially with regards to layering images, and animations.

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

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T03:16:55-07:00
by dahans
Hi, i read many times about this problem and now i run in for myself, i tried anything to solve this problem but without success

the error : convert: geometry does not contain image `picture.png' @ warning/attribute.c/GetImageBoundingBox/244.
throws when im running this command: convert 'picture.png' -trim -profile 'sRGB.icc' -verbose 'image.png'
the output was: picture.png=>image.png PNG 970x1261=>1x1 970x1261-1-1 8-bit sRGB 2c 0.080u 0:00.079

all attempts by adding +repage without success


Edit:
Version: ImageMagick 6.8.0-7 2013-02-27 Q16

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T04:16:32-07:00
by snibgo
1x1 970x1261-1-1
You have trimmed the image to nothing, zero size.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T04:25:32-07:00
by dahans
it is not able to save empty images ?

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T04:46:54-07:00
by snibgo
Sadly, no.

I think it should handle zero images, in the same way that arithmetic can handle zero numbers. I think I read that version 7 will be able to do so.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T05:48:44-07:00
by magick
Its probably not difficult to support "zero" images. Can you post a few use cases where you would use "zero" images but fail to work now? What are some specific command-line examples that produce an exception rather than a zero image? We'll use these examples to test our patches to support "zero" images.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T06:56:33-07:00
by snibgo
Here is a Windows script of some examples, off the top of my head. In each example, I've added a comment about whether I think the result is correct.

It seems IM mostly handles zero images appropriately. It may throw a warning, but not an error. (I note that the OP had a warning, not an error.)

Hence, I mostly retract my comment above: I now think IM does (mostly) handle zero images correctly.

Code: Select all

set IP=%IMG683%

"%IP%convert" ^
  -size 100x100 xc:Red -trim ^
  zeroA.png
rem
rem No problem.

"%IP%convert" ^
  -size 100x100 xc:Red -trim ^
  -unique-colors ^
  zeroB.png
rem
rem No problem.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  ( +clone -trim ) ^
  -composite ^
  shouldBeRed.png
rem
rem No problem.

"%IP%convert" ^
  zeroA.png ^
  -resize "100x200^!" ^
  zeroResized.png
"%IP%identify" zeroResized.png
rem
rem No problem.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  -remap zeroB.png ^
  weird.png
"%IP%identify" weird.png
rem
rem weird.png is black. I'm not sure if this is reasonable.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  zeroA.png ^
  -compose Divide_Src -composite ^
  divideZero.png
rem
rem divideZero.png is 100x100 Red, which is reasonable.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  zeroA.png ^
  -compose Multiply -composite ^
  multiplyZero.png
rem
rem multiplyZero.png is 100x100 Red, which is reasonable.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  zeroA.png ^
  -compose Add -composite ^
  addZero.png
rem
rem addZero.png is 100x100 Red, which is reasonable.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  zeroA.png ^
  -compose Difference -composite ^
  differenceZero.png
rem
rem differenceZero.png is 100x100 Red, which is reasonable.

"%IP%convert" ^
  -size 100x100 xc:Red ^
  zeroA.png ^
  -compose Displace -composite ^
  displaceZero.png
"%IP%identify" displaceZero.png
rem
rem displaceZero.png is roughly black, but should be 100x100 Red


"%IP%composite" ^
  -size 100x100 xc:Red ^
  zeroA.png ^
  -displace 10x20 ^
  badResult.png

"%IP%identify" badResult.png
rem
rem badResult is zero image but should be 100x100 Red

"%IP%convert" ^
  zeroA.png ^
  txt:
rem
rem Output is one pixel (transparent white). Output should be no pixels.
EDIT: correction to my comment to the last example: the output is transparent white, not transparent black.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T08:03:57-07:00
by magick
Stand by, we'll investigate the issue.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T09:05:20-07:00
by snibgo
I don't know what file formats support zero images. If a format mandates a minimum size 1x1, I think IM should be consistent in what it puts there.

Code: Select all

"%IP%convert" ^
  -size 100x100 xc:Red -trim ^
  txt:
rem
rem Creates 1x1, transparent white

"%IP%convert" ^
  -size 100x100 xc:Red -trim ^
  zero.gif
"%IP%identify" zero.gif
rem
rem zero.gif is 1x1 transparent black
"%IP%identify" -verbose zero.gif

"%IP%convert" ^
  -size 100x100 xc:Red -trim ^
  zero.tiff
"%IP%identify" zero.tiff
rem
rem zero.tiff is 1x1 transparent white
"%IP%identify" -verbose zero.tiff

"%IP%convert" ^
  -size 100x100 xc:Red -trim ^
  zero.jpg
"%IP%identify" zero.jpg
rem
rem Creates 1x1 white (JPG doesn't support transparency, of course).
"%IP%identify" -verbose zero.jpg

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T15:23:16-07:00
by glennrp
snibgo wrote:I don't know what file formats support zero images. If a format mandates a minimum size 1x1, I think IM should be consistent in what it puts there.
PNG specifies a minimum image size of 1x1, but the oFFs chunk allows all of the pixels to be off the page/canvas/screen/whatever. "-repage" prevents the oFFs chunk from being written.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T18:50:01-07:00
by anthony
snibgo wrote:Sadly, no.

I think it should handle zero images, in the same way that arithmetic can handle zero numbers. I think I read that version 7 will be able to do so.
It isn't that simple. No image file format I know of allows a zero sized image.

Really a zero sized image is just non-sensical.

When this happens the 1x1 image, is fully-transparent, as is marked as being a 'NULL' image.

NOTE it is a warning, as it is NOT an error!

GIF animations often will throw up a null image. They are required to hold the timing and meta-data that the original 'frame' contained, but otherwise no-longer take part in the animation sequence. You do not want IM to error abort when this happens. -layers RemoveDups will generally remove Null images correctly for GIF animations.
Examples...
http://www.imagemagick.org/Usage/anim_mods/#crop

Null image handling, removal, and reporting (as in identify output) is an area that could use a little more work.

I have wanted to add a -layers 'RemoveNull' operator, but never got round to it.

Re: unexpected error "convert: geometry does not contain ima

Posted: 2013-02-28T19:47:36-07:00
by snibgo
I have mostly retracted that statement. IM does handle zero-sized images.
anthony wrote:Really a zero sized image is just non-sensical.
Is it? No more so, I think, than a zero-length string in a program.