Sign up ×
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.

Suppose I have a image named 1.png which is currently

500px : height
1000px : width

I want to resize it to:

50px : height
100px : width

It must be output in PNG format, not JPG. An example would be highly appreciated.

share|improve this question
Your best bet is Imagemagick – r004 Jun 26 '14 at 11:47
If the idea is to create thumbnails see and the various thumbnailer applications (see apt-cache search thumbnailer on a Debian-based system for instance). – Stéphane Chazelas Jun 26 '14 at 12:30

4 Answers 4

I'd use convert or mogrify from the ImageMagick suite.

convert -resize 100x50 1.png 2.png

(mogrify doesn't take the output file name and modifies the file in place).

share|improve this answer

The answers you have gotten so far will work in this particular case because your source and target images have the same aspect ratio. However, if you want to change to an arbitrary size, they will fail:

$ file foo.png 
foo.png: PNG image data, 1000 x 500, 8-bit/color RGB, non-interlaced
$ convert -resize 100x50 foo.png bar.png
$ file bar.png 
bar.png: PNG image data, 100 x 50, 8-bit colormap, non-interlaced

As you can see above, the simple convert works fine when not changing the image's proportions. But what if you want to change them?

$ convert -resize 200x50 foo.png bar.png
$ file bar.png 
bar.png: PNG image data, 100 x 50, 8-bit colormap, non-interlaced

So, when changing the proportions, the command above fails. In order to force convert to change an image this way, you need to add a ! to the end of the geometry specification (and, since ! is a special character to many shells, you need to escape it as \!):

$ convert -resize 200x50\! foo.png bar.png
$ file bar.png 
bar.png: PNG image data, 200 x 50, 8-bit colormap, non-interlaced
share|improve this answer

Use Imagemagick for this.

Read the man page for correct use but it should work by passing parameters, something like

convert 1.png -resize 50x100 1-resized.png

share|improve this answer
At least on Debian, the man pages for ImageMagick tools are useless (except at pointing out where to find the real information like file:///usr/share/doc/imagemagick/www/convert.html or (though that latter one might be for a different version of ImageMagick)). – Stéphane Chazelas Jun 26 '14 at 12:15
The geometry argument is actually (in it's simplest form) "widthxheight", so it should be -resize 100x50 – Popup Jun 26 '14 at 12:50

An alternative to ImageMagick is the venerable netpbm:

pngtopnm input.png | pnmscale -reduce 10 | pnmtopng > output.png
share|improve this answer

Your Answer


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