How to batch convert png photos to jpg or vice versa


Example: you have an folder /root/fff7860c7319fa20c8340eb813637fba-i/ with many photos like this figure:

batch convert png photos to jpg

And you want to convert all pagepng-*.png files to jpg format. How to do this ?

Step 1: install ImageMagick
How to install ImageMagick on CentOS 7

Step 2: change dir to photos directory

cd /root/fff7860c7319fa20c8340eb813637fba-i

Step 3:
Linux:

mogrify -format jpg pagepng-*.png

Windows:

C:/ImageMagick/mogrify.exe -format jpg pagepng-*.png

Done!, now you have many jpg photos.
batch convert png photos to jpg 2

You can specify quality of JPEG output:

C:/ImageMagick/mogrify.exe -quality 60 -format jpg pagepng-*.png

Custom output path:

C:/ImageMagick/mogrify.exe -path /path/to/output -format jpg pagepng-*.png

If you don’t use step 2, you can use this command for step 3:

mogrify -path /root/fff7860c7319fa20c8340eb813637fba-i -format jpg /root/fff7860c7319fa20c8340eb813637fba-i/pagepng-*.png

Leave a Reply