unexpected error "convert: geometry does not contain image"

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Just out of curiosity, under what conditions would one want to use a zero sized image? What kind of operation would need that?

Right now one can use null: for a placeholder image in IM.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Some operations might naturally result in a zero-size image. For example:

- trimming a constant-colour image (IM handles this well)
- cropping to 0x0+0+0 (IM does error abort)
- resizing to 0x0! (IM does error abort)
- SRT with scale 0 (IM does error abort)
- resize a 100x100 image to 0.4% (IM does error abort)

If I am creating a picture-in-picture video effect, I might want to shrink an image away to nothing, each time compositing over some backdrop. IM could do that with "-resize", but it won't. When the image should be smaller than 0.5x0.5 pixels, it bombs out. SRT works correctly with very small values of scale, but for no reason that I can think of, it won't accept a zero scale.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Oh, yes, and

Code: Select all

convert -size 0x0 xc:Red r.png
gives me a 1x1 image that is red. Why doesn't it give the same result as

Code: Select all

convert -size 100x100 xc:Red -trim r.png
? No reason that I can think of.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

With respect to resizing and possibly other things, one certainly can do computations before hand and then either do or skip the operation if it leads to too small or zero sized images.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

cropping with 0x0 means crop using the virtual canvas size!
With 0x0+0+0 it means crop image to the virtual canvas!

Generally that does not produce a 0 sized image, but as with any crop, it can. It may even generate a resulting image with non-zero virtual offset.

NOTE The actual image may not be fully contained by its virtual canvas, a fact used in some GIF animations (and which IE 8 has problems with). It can have an offset that places it beyond the bounds (positive or negative) of the virtual canvas (which is always a positive size starting at origin).

Actually such a crop would be useful in GIF animations!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

snibgo wrote:Oh, yes, and

Code: Select all

convert -size 0x0 xc:Red r.png
gives me a 1x1 image that is red. Why doesn't it give the same result as

Code: Select all

convert -size 100x100 xc:Red -trim r.png
? No reason that I can think of.
-size 0x0 means Default size which for a canvas (xc:) means a 1x1 single pixel image. For labels it means fit the image size to text bounds.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply