Let's say you have lots of images and want to upload them to Facebook or to your website but you have to resize or edit all the images to suitable size for faster web access without losing too much of the quality of them. One tool to help you in this situation is mogrify.
mogrify is in imagemagick package. So you just need to install the package to get it. How to use it? Let's see some examples below:
1. mogrify -resize 320x240 *.jpg
This command will resize all files ending with .jpg (jpeg image) to resolution of 320x240 and replace all the files with the same name. mogrify may not produce the exact resolution to preserve aspect ratio.
2.mogrify -path Image-Small/ -resize 800x600 -density 25x25 *.gif
This command will resize all images ending with .gif to 800x600 with density 25x25. The resized images will be saved in Image-Small directory. So the original files is unmodified.
3. mogrify -resize 50% rose.jpg
This will resize the image to 50% and the original file replaced.
4. mogrify -format jpg *.png
This will convert all png files in currect directory to jpeg.
mogrify has many options for you to explore. Just man mogrify to read the manual or go to http://www.imagemagick.org/www/mogrify.html. For more command-line examples, go here.
3 comments:
This helped me out, thanks.
You can go parallel:
mkdir pngs && parallel mogrify -path pngs -format png {} ::: *.tif
This converts all tif images in the current working dir to png and saves them in pngs folder in parallel.
Boris,
Thank you for the tip.
Post a Comment