Baalrukh wrote: ↑2017-09-06T08:39:36-07:00I'm trying to resize a 1x14 image to 33% with the following command:
[...]
To give a little more context, the resize of the image is done while processing a batch of images, and I have no way to known beforehand that I may process a 1 pixel wide image.
Is there a way around this issue ?
Using IM7 you can use something like this...
Code: Select all
magick myImage.png -strip -resize "%[fx:w*0.33>1?w*0.33:1]x%[fx:h*0.33>1?h*0.33:1]" png32:output.png
If 33% of the width or height is less than 1, it will resize it to 1. It won't attempt to resize it to a dimension less than one pixel, and you shouldn't get that error.
If you want it to resize one dimension even if the other dimension would be less than 1, put an exclamation point after the "-resize" dimensions like this...
Code: Select all
... -resize "%[fx:w*0.33>1?w*0.33:1]x%[fx:h*0.33>1?h*0.33:1]!" ...
The double quotes around the "-resize" dimensions are required to prevent Windows from interpreting the greater-than signs ">" as redirects. Also, in a Windows BAT script you'll need to change all the single percent signs "%" to doubles "%%".