convert: NegativeOrZeroImageSize when resizing / scaling

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.
Post Reply
canavan
Posts: 23
Joined: 2013-02-18T10:12:03-07:00
Authentication code: 6789

convert: NegativeOrZeroImageSize when resizing / scaling

Post by canavan »

convert with -resize / -scale aborts with a NegativeOrZeroImageSize error if an image is reduced in size and one dimension is rounded down to zero. I'm using ImageMagick 7.0.2-6 on Ubuntu x64 16.04.

Examples:

Code: Select all

$ convert -size 1000x1 xc:red -resize 49% /tmp/r.png
convert: NegativeOrZeroImageSize `red' @ error/resize.c/ResizeImage/2855.
$ convert -size 1000x1 xc:red -scale 49% /tmp/r.png
convert: NegativeOrZeroImageSize `red' @ error/resize.c/ScaleImage/3225.
$ convert -size 1000x10 xc:red -scale 4% /tmp/r.png
convert: NegativeOrZeroImageSize `red' @ error/resize.c/ScaleImage/3225.
$ convert -size 10x1000 xc:red -scale 4% /tmp/r.png
convert: NegativeOrZeroImageSize `red' @ error/resize.c/ScaleImage/3225.
$ convert -size 10x1000 xc:red -resize 10@ /tmp/r.png
convert: NegativeOrZeroImageSize `red' @ error/resize.c/ResizeImage/2855.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert: NegativeOrZeroImageSize when resizing / scaling

Post by snibgo »

Yes, that's what happens. IM won't create images with zero or negative dimensions. This isn't a bug, but by design.

What would you prefer it did instead?
snibgo's IM pages: im.snibgo.com
canavan
Posts: 23
Joined: 2013-02-18T10:12:03-07:00
Authentication code: 6789

Re: convert: NegativeOrZeroImageSize when resizing / scaling

Post by canavan »

I'd prefer it to round to 1 instead of 0. Throwing an exception is still OK if the user explicitly specifies a width or height of 0.

This behaviour was considered a bug in the past, for example in viewtopic.php?t=9082
Post Reply