Reputation: 348
I am trying to apply a resize limit for ImageMagick but it does't seem to work as supposed in the docs. I am using ImageMagick 6.9.2-3-portable-Q16-x86 in Windows 7.
convert input.jpg -resize 1920x1080^> -quality 92 output.jpg
When the input file is larger that 1920x1080, it gets resized nicely.
When the input file is smaller, e.g. 1024x768, although I would expect it to be untouched, it does get saved with the same resolution (1024x768) and different file size, depending on the quality set.
Shouldn't parameter -resize 1920x1080^>
force ImageMagick to skip that file?
If not, then how can we skip those files that are smaller than the resize limit set?
Upvotes: 0
Views: 91
Reputation: 207465
It is supposed to work like that... your command says "Take input.jpg
and resize it if larger than 1920x1080, then change its quality and save it."
You can run something like this before you execute your command to see if it needs resizing - it will output 1
or 0
depending on whether the image needs resizing or not:
identify -format "%[fx:(w>1920)||(h>1080)?1:0]" 1921x1080.jpg
1
identify -format "%[fx:(w>1920)||(h>1080)?1:0]" 1920x1080.jpg
0
If you want to put that 0
or 1
in a variable, you do something like:
for /f "usebackq" %i in ( `identify -format "%[fx:(w>1920)||(h>1080)?1:0]" 1921x1080.jpg` ) do set resize=%i
and double up the percent signs in a .BAT
file.
Upvotes: 1