Page 2 of 2

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

Posted: 2013-02-28T19:57:59-07:00
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.

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

Posted: 2013-02-28T20:37:05-07:00
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.

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

Posted: 2013-02-28T20:53:06-07:00
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.

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

Posted: 2013-02-28T21:35:46-07:00
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.

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

Posted: 2013-02-28T21:41:39-07:00
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!

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

Posted: 2013-02-28T21:43:36-07:00
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.