Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Thursday, August 4, 2016 at 19:23


This is a short compilation of 6 bulk processing command line examples from 6 of our previous articles about bulk images converting, resizing, reducing (file size), rotating, and flipping. Here we mention only the title and the command lines, without the explanations (but we give a link to the corresponding article), for every action of processing below. For those don't know, the command lines here are basically just bash looping commands combined with ImageMagick's convert command lines.



1. Bulk Converting Images Format



PNG to JPEG:

for i in *.png; do convert -verbose "$i" "`echo $i | sed 's/.png/.jpeg/g'`"; done


JPEG to PNG:

for i in *.jpeg; do convert -verbose "$i" "`echo $i | sed 's/.jpeg/.png/g'`"; done

Corresponding article: http://www.ubuntubuzz.com/2016/07/bulk-converting-png-or-jpeg-with-imagemagick-command-lines.html.


2. Bulk Resizing (By Percentages)



25%:

for i in *.png; do convert -verbose -resize 25% "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done


50%:

for i in *.png; do convert -verbose -resize 50% "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done


75%:

for i in *.png; do convert -verbose -resize 75% "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done

Corresponding article http://www.ubuntubuzz.com/2016/07/bulk-resizing-images-with-imagemagick-command-lines.html.

3. Bulk Resizing (By Resolutions)



600x400:

for i in *.png; do convert -verbose -resize 600x400 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done


800x600:

for i in *.png; do convert -verbose -resize 800x600 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done


1024x768:

for i in *.png; do convert -verbose -resize 1024x768 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done


Corresponding article: http://www.ubuntubuzz.com/2016/07/bulk-resizing-images-by-resolutions.html.

4. Bulk Reducing Files Size



PNG:

for i in *.png; do convert -verbose -colors 128 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done



JPEG:
for i in *.jpeg; do convert -verbose -quality 50 "$i" "`echo $i | sed 's/.jpeg/-converted.jpeg/g'`"; done

Corresponding article: http://www.ubuntubuzz.com/2016/07/bulk-reducing-image-files-size-with-imagemagick-command-lines.html.

5. Bulk Rotating 



120 degrees

for i in *.png; do convert -verbose -rotate 120 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done;


45 degrees

for i in *.png; do convert -verbose -rotate 45 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done;


75 degrees

for i in *.png; do convert -verbose -rotate 75 "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done;


Corresponding article: http://www.ubuntubuzz.com/2016/07/bulk-rotating-image-files-with-imagemagick-command-lines.html.

6. Bulk Flipping 


Vertical: 

for i in *.png; do convert -verbose -flip "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done;


Horizontal: 

for i in *.png; do convert -verbose -flop "$i" "`echo $i | sed 's/.png/-converted.png/g'`"; done;


Corresponding article: http://www.ubuntubuzz.com/2016/07/bulk-flipping-image-files-with.html.