ImageMagick change image width and height -
i using imagemagick resize image resolution using below command-line option
convert abc.png -set units pixelsperinch -density 75 abc_a.png
i in need of this: if images has more 300 width or more 100 height, want convert width 300 width , 100 height, changing above dpi (i.e. 75dpi).
can 1 help me on this?
if on linux/osx, can image dimensions this:
identify -format "%w %h" input.jpg so, if want width , height in variables w , h, this:
read w h < <(identify -format "%w %h" input.jpg) now can test width , height , farther processing if necessary:
[ $w -gt 300 -o $h -gt 100 ] && convert input.jpg -set units ... or, if want more verbose:
if [ $w -gt 300 -o $h -gt 100 ]; convert ... fi so, total solution proposing looks this:
#!/usr/bin/bash read w h < <(identify -format "%w %h" input.jpg) [ $w -gt 300 -o $h -gt 100 ] && convert input.jpg -set units ... jpeg or png makes no difference, replace jpg png if format of choice.
updated windows
ok, no-one else helping out (very) rusty windows skills. image width under windows:
identify -format "%w" input.png > w.txt set /p w=<w.txt now height:
identify -format "%h" input.png > h.txt set /p h=<h.txt you should have width , height of image input.png in 2 variables, w , h, check typing
echo %w% echo %h% now need if statements:
if %w% leq 300 goto skip if %h% leq 100 goto skip convert .... :skip note:: may need ^ in front end of percent sign in windows.
note: may need double @ signs in scripts because windows illogical.
image imagemagick imagemagick-convert
No comments:
Post a Comment