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.
unexpected error "convert: geometry does not contain image"
-
- 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
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.
- 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
-
- 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
Oh, yes, andgives me a 1x1 image that is red. Why doesn't it give the same result as ? No reason that I can think of.
Code: Select all
convert -size 0x0 xc:Red r.png
Code: Select all
convert -size 100x100 xc:Red -trim r.png
snibgo's IM pages: im.snibgo.com
- 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
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.
- 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
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!
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/
https://imagemagick.org/Usage/
- 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
-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.snibgo wrote:Oh, yes, andgives me a 1x1 image that is red. Why doesn't it give the same result asCode: Select all
convert -size 0x0 xc:Red r.png
? No reason that I can think of.Code: Select all
convert -size 100x100 xc:Red -trim r.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/