Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a bunch of PNG files that I want to rescale.

Oversimplifying a little, let's say I have files named:

  • apple@2x.png
  • orange@2x.png
  • pear@2x.png

and so on, and I want to make:

  • apple.png
  • orange.png
  • pear.png,

and so on, with the output files all at half the scale of the corresponding input files.

Is there a good tool for that?

I have about 200 input files, so preferably the whole process would be automated.

EDIT: I'm on a mac.

share
2  
If you tell people what operating system you're using, you'd get more detailed instructions. –  frabjous Dec 30 '10 at 5:17

5 Answers 5

up vote 6 down vote accepted

Yep as mentioned by Ignacio, the convert function from ImageMagick can do so.

If you have access to a Unix based shell, e.g. Linux or Mac terminal, something like this will do:

cd folder-with-the-png-files
for i in *.png; do convert $i -resize 50% ${i/.png/}.resized.png; done

The above command will resize all the images in the folder and save them as xxx.resized.jpg.

Note however, that you may need to install ImageMagick first...

share
    
You should also quote your variables. –  Ignacio Vazquez-Abrams Dec 30 '10 at 6:06
    
oops. oh and it should read xxx.resized.png rather than .jpg –  Reuben L. Dec 30 '10 at 8:45
    
OK, Thanks. I got this to work for one file, but I'm not used to this syntax, can you fix it so it will work for many files? –  William Jockusch Dec 30 '10 at 15:23
    
OK, for something similar just converting pdfs to pngs, I tried for i in "".pdf; do convert $i "".png; done which converted them all right, but the resulting names were *-1.png, *-2.png, *-3.png, and so on. How do I preserve the file names? –  William Jockusch Dec 30 '10 at 19:18
1  
this should work: for i in *.pdf, do convert $i ${i/.pdf/}.png; done –  Reuben L. Dec 31 '10 at 0:20

ImageMagick's convert can do this. Just use your shell's facilities for looping over a set of files.

share

If you're still on Windows XP, you can use Image Resizer.

On Windows 7, there's a similar tool.

share

I like using the free Irfanview for this. It has in the same batch convert dialog a batch renamer (which can use variables for advanced renaming) and batch converter. Just hit "b" key when you open Irfanview, or select from File top menu. You can also use a command line mode if wish so.

In batch dialog, if you click on Advanced Options you can there do many operations to add to your batch, like for example, batch rescale in many ways, and ideally with lanczos algorythm selected (great quality). You can add a sharpen filter, etc.

share

Just for completeness, here is the answer to my original question:

for i in *@2x.png; do convert $i -resize 50% ${i/@2x.png/}.png; done
share

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .