ImageMagick is a set of tools for manipulating and editing images directly from the shell.
In this tip we'll talk only about the convert command, which is part of ImageMagick.
It's often useful to shrink images taken with a digital camera before uploading them to the internet. Digital camera images can easily reach 20 Megabytes, so shrinking them saves upload time.
So let's get to it. The first thing is to install imagemagick:
sudo apt-get update
sudo apt-get install imagemagick
With imagemagick installed, go into the folder that contains your images and create a folder that we'll call "reduzidas" in this example, then run the following command, adjusting the parameters to your liking.
mkdir reduzidas
find . -maxdepth 1 -iname "*.jpg" | xargs -l -i convert -resize 1920x1080 -quality 70% -density 72 {} ./reduzidas/{}
- find . -maxdepth 1 -iname "*.jpg": this command lists only the images with a jpg extension in the current directory, without descending into subdirectories (-maxdepth 1).
- xargs -l -i runs the convert command, passing it the file names that the find command found.
- convert is ImageMagick's command for format conversion.
- -resize 1920×1080: change this to the dimensions the file will have after resizing.
- -quality 70%: only applies to JPG. Change this to the quality of the final jpg. 0% – 100%.
- -density 72: image DPI. In my case I have several images at 300 DPI and I want them at 72. You can omit this option if you don't need to change the dpi.
- ./reduzidas/: directory where the resized images will be saved.
That’s all folks!

Comments 4
vlw, cara. mto bom
😉
e se eu quise-se redimencionar e trocar de png para icon por exemplo?
Este comando resolveria: