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

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 imagemagick.org/Usage/thumbnails 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

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

$ convert -resize 100x50 1.png 2.png

# or #

$ mogrify -resize 100x50 1.png

convert takes a separate output filename; creating a separate file.
mogrify doesn't take a separate output filename; modifying 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 imagemagick.org/script/convert.php (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
Is pngtopnm really well known/respected? This is the first I've heard of it. – tjt263 Feb 24 at 4:01

Your Answer


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