Resize multiple images in one go
Resize Images, since the photo editing programs have become part of the routine of the average, is a task as simple as trivial. It is used especially for smaller size is available save bandwidth on the transfer of the file: smaller image will load faster and also to use the images on the web is not the high resolution needed. The problem arises when we have a considerable number of images to be resized, open them one by one can become quite long and tedious.
One of the solutions is “David’s Batch Processor“, a plugin for Gimp that allows you to run some filters on multiple images, including the “Resize” to resize.
“David’s Batch Processor” can be fun to discover, and can certainly speed up the work that otherwise we would hand, but compared to other programs is slow. I know the fastest way to resize multiple images in one go is the command line. ImageMagick is a small yet powerful command line tool (obtained via the web as added library to PHP). ImageMagick is a program that includes several commands, Today we see a couple.
The command “
convert” converts the input image and creates a copy. Eventually we will have processing the initial image and the converted image. With “
convert” you can not overwrite an image.
Now let's see how it is possible change the size of an image:
convert -geometry 1024x 1.jpg 1_mod.jpg
This command resizes the long side image “1.jpg” a 1024px, maintaining unchanged proportions.
for i in *.jpg; do convert -geometry 1024x $i thumb-$i; done
This other command performs the same work, but converts all images with estensione “.jpg” 1024px to the side.
for i in *.jpg; do convert -scale 50% $i thumb-$i; done
This other command uses the argument “
scale” in place of “
geometry“. The argument “
scale” is used together with the percentage of reduction / magnification image. In this case the image will be halved.
convert originale.jpg originale.png
Should be noted that “
convert” can also be used to change the file extension (will always create a copy without overwriting).
The command “
mogrify” is virtually identical to the command “
convert“, the difference is that it will not create a copy of the original, but overwrite the input image. Eye so you do not overwrite if it is not exactly what you want to do.
In a few minutes we finished to resize our images, and we did not do the job manually. A real godsend.