If the previous article talked about bulk resizing, this article talks about reducing multiple image files size. This can be achieved by many ways. We give some examples in the way of reducing the colors (PNG) and using -quality option (JPEG). We separate PNG and JPEG because they have these different commands.



1) PNG


Color 128

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

Note: this command will reduce the image colors into 128. In our example, every image size reduced approximately in half.

Color 32

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

Note: this command will reduce every image colors into 32. In our example, every image size reduced approximately 1/5 of the original file.




2) JPEG

 


value=50


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


value=20


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

Sample Results


value=50 resulting in about 1/4 of the original.



value=20 resulting in 1/8 of the original.


, , , , , ,