How to Resize Images by Command line in Ubuntu

imgp command line tool lets you resize images from the Terminal.

If you have been following us, you might have seen our article on how to add resize option in the right-click context menu in the File manager in Ubuntu. Today, let’s talk about how to resize images by command line via Terminal. Command line way of doing things have their own advantages. In most of the cases, it is highly efficient to use command line when doing things from a remote computer. Also, Terminal consumes the least amount of system resources and is lightning fast.

Resizing images from the Terminal in Ubuntu

To resize images from the terminal, we will be using a free command line utility called imgp. This amazing utility supports batch processing of images and uses the intelligent adaptive algorithm.

Features of imgp

Though the name of the utility could have been better, the features aren’t compromised.  imgp is a good replacement of the Nautilus Image Converter extension because it is not tied to any file manager and so way faster in conversion.

Let’s take a look at its powerful features.

  • supports JPEG and PNG image formats
  • can resize by percentage or resolution
  • supports batch processing of images
  • preserves/ erase EXIF data
  • can rotate images clockwise by the specified angle
  • optimize images
  • specify output JPEG quality
  • completion scripts for bash, fish, zsh

Installation of imgp in Ubuntu, Linux Mint, and elementary OS

The easiest way to install imgp is to via PPA.

Step 1) Launch Terminal.

Step 2) imgp needs Python 3.5 or later, which is installed by default in recent versions of Ubuntu, but in any case, there is no harm in entering this command:

sudo apt-get install python3-pil

Step 3) Use the following command to add PPA.

sudo add-apt-repository ppa:twodopeshaggy/jarun

Step 4) Update:

sudo apt update

Step 5) Install imgp

sudo apt install imgp

That’s it! You can now use the command line to start resizing your images.

How to use imgp

Convert some images and directories:

imgp -x 1366x768 ~/ ~/Pictures/image3.png ~/Downloads/
3840x2160 -> 1365x768
11104999 bytes -> 1486426 bytes

2048x1365 -> 1152x768
224642 bytes -> 31421 bytes

1920x1080 -> 1365x768
2811155 bytes -> 1657474 bytes

2048x1365 -> 1152x768
224642 bytes -> 31421 bytes

Scale an image by 75% and overwrite the source image:

imgp -x 75 -w ~/image.jpg
1366x767 -> 1025x575
120968 bytes -> 45040 bytes

Rotate an image clockwise by 90 degrees:

imgp -o 90 ~/image.jpg
120968 bytes -> 72038 bytes

Adapt the images in the current directory to 1366×1000 resolution.

Visit all directories recursively, overwrite source images, ignore images with matching hres or vres but convert PNG images to JPEG.

imgp -x 1366x1000 -wrack
Set hres=800 and adapt vres maintaining the ratio.

imgp -x 800x0
Source omitted. Processing current directory...

1366x911 -> 800x534
69022 bytes -> 35123 bytes

1050x1400 -> 800x1067
458092 bytes -> 78089 bytes

Process images greater than 50KB (50*1024 bytes) only:

imgp -wrackx 1366x1000 -s 51200


Kiran Kumar
Hi there! I'm Kiran Kumar, founder of I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities especially during Winter ;). When I'm not writing for FOSSLinux, I'm seen biking and hiking on scenic trails. Hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more, and spread Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day!


Please enter your comment!
Please enter your name here




Create a ClamAV Antivirus Live USB drive, and how to use it

Antivirus Live CD or USB drives come in handy at times when your computer is infected with a virus and other malware. Here is how you can create a ClamAV Live USB drive to scan and remove the malware from a computer.
best linux distros for laptops
Whether buying a Linux pre-installed laptop or selecting a Linux distro for your existing laptop, there are many things to consider. Let's take you through some of the best Linux distros that are optimized for Laptops in this 2019 edition of the article. Read on.
manjaro screenshots
Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.
best music players for linux
For sure, there will be Linux users out there who cannot live without music. If you're one of those people, you would know how important it is to have a good music player installed on your computer system. In this article, we present to you the 5 Best Music Players for Linux, which will hopefully be able to satisfy each of our readers' needs.