Next, different solutions for various problems that are presented to us daily and this time, they teach us how to resize images through the terminal using two tools that belong to the package Imagemagick.
As they tell us in the original article:
In the first instance both have similarities, although mogrify transforms the image by replacing the original file while convert save the result in a new file. TO mogrify only the image to be transformed is passed as an argument, while convert, the image we want to transform and the name of the file where the result will be saved.
Convert
Let's first see how to do various tasks with convert:
Cut an image in half and save the result to file file2.jpg:
$ convert -resize 50% file.jpg file2.jpg
Resize the image file.jpg to 400 × 300 and save the result in the file file2.jpg:
$ convert -resize 400×300 file.jpg file2.jpg
Halve all photos and save the result in other files:
$ convert -resize 50% *
mogrify
Cut the image file.jpg in half:
mogrify -resize 50% file.jpg
Resize the image file.jpg to 400 × 300:
mogrify -resize 400×300 file.jpg
Halve all photos:
mogrify -resize 50% *