5

I have a lot of .png images in a folder. Is there a command (or software) that can convert all them to .jpg and (simultaneously) rescale the created .jpg files to 25% of their original size?

14

Use the convert command from ImageMagick:

convert x.png -resize 25% x.jpg

will create a 25%-scaled JPEG version of x.png.

To do all the PNG files at once, use a for loop:

for filename in *.png ; do convert "$filename" -resize 25% "${filename%.png}.jpg" ; done

We look at every file matching *.png, and for each one run the convert command above. "${filename%.png}.jpg" generates the .jpg filename for each .png: it removes the extension with % and puts .jpg back on the end.

| improve this answer | |
2

You could use mogrify to batch convert & resize all .png images in the current directory:

mogrify -resize 25% -format jpg *.png

because it uses -format jpg the original .png images are left untouched
(when format is the same or missing the originals are overwritten).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.