Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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