Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 12 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

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).

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.