I have Ubuntu 10.04. I have converted image through terminal using the following command:

convert myfigure.png myfigure.jpg

But I want to resize the height and width of the converted image. Is there any way to do this?


4 Answers 4


Same command, with an extra option:

convert myfigure.png -resize 200x100 myfigure.jpg


convert -resize 50% myfigure.png myfigure.jpg

To resize multiple files, you can try the following command (as suggested by @test30)

find . -maxdepth 1 -iname "*.jpg" | xargs -L1 -I{} convert -resize 30% "{}" _resized/"{}"
  • 17
    You can also use percentage, as in convert -resize 50% myfigure.png myfigure.jpg
    – January
    Mar 24, 2013 at 9:48
  • @January excellent :)
    – Rinzwind
    Mar 24, 2013 at 9:56
  • If I want to convert all images in a folder what's the best command then? does convert -resize 50% *.JPG work? tnx Sep 7, 2014 at 19:30
  • 7
    resize all images in current dir by 50% find -maxdepth 1 . -iname "*.jpg" | xargs -l -i convert -resize 50% {} /tmp/{} src: perturb.org/display/632_ImageMagick_resize_images.html I added maxdepth :)
    – test30
    Dec 10, 2014 at 21:57
  • 5
    Found that to do all the pictures the . needed to be before -maxdepth so it should be this: find . -maxdepth 1 -iname "*.JPG" | xargs -l -i convert -resize 25% {} email/{} Jul 9, 2015 at 22:58

If you want CLI only:

sudo apt-get install imagemagick
mogrify -resize 320x240 Image.png 
mogrify -resize 50% Image.png
mogrify -resize 320x240 *.jpg

If you wanna try GUI:

Install nautilus-image-converter

sudo apt-get install nautilus-image-converter

It adds two context menu items in nautlius so you can right click and choose "Resize Image".(The other is "Rotate Image").

You can do a whole directory of images in one go if you like and you don't even have to open up an application to do so.

  • 1
    Is there any more capable CLI software than this? It crashes and works on approx 80% images.
    – Luka
    Mar 29, 2018 at 19:24

imgp is a relatively new utility that does image resize and rotation. It has more features than nautilus-image-converter.

For example:

imgp -x 1366x768 *

Since Ubuntu ships with Python, you can also use a Python script to achieve this with a little more control over what happens - see this stackoverflow question for example scripts. Those examples use just the standard library.

Script #1

import os, sys
import Image

size = 128, 128

for infile in sys.argv[1:]:
    outfile = os.path.splitext(infile)[0] + ".thumbnail"
    if infile != outfile:
            im = Image.open(infile)
            im.thumbnail(size, Image.ANTIALIAS)
            im.save(outfile, "JPEG")
        except IOError:
            print "cannot create thumbnail for '%s'" % infile

And another example where you only have to specify the width (as the width variable):

Script #2

from PIL import Image
import sys

filename = sys.argv[1:]
basewidth = 300
img = Image.open(filename)
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)

Now, how to do this through the terminal...

sudo nano resizescript.py

Paste one of those blocks of code into the text editor. Ctrl+x to exit (say yes to save changes).

To use Script #1:

python resizescript.py yourfilenamehere.jpg

To use Script #2:

python resizescript.py yourfilenamehere.jpg

You must be in the same directory as the picture files for both of these scripts. The first one shrinks the image to 128x128 pixels. The second script makes it 300 pixels wide and calculates the proportional height. This is more of a Python answer, but it is done all through the terminal technically.

  • please include example(s) here
    – Zanna
    Sep 10, 2017 at 20:20
  • Please provide the example through the terminal as per question.
    – kenorb
    Sep 10, 2017 at 21:10
  • Thanks, I assumed too much in my first answer. I have made the edits per question.
    – freeworld
    Sep 12, 2017 at 0:05
  • Note that PIL is only available for Python 2; support for 3.x is planned "later" as per pythonware.com/products/pil
    – arp
    Jan 21, 2018 at 16:13
  • For Python 3 there's Pillow - that's a fork of PIL. Confusingly enough it's in Debian repositories under python3-pil package. Aside from that, it's available via pip3 package manager. Dec 2, 2018 at 9:32

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