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/
/home/testuser/image1.png
3840x2160 -> 1365x768
11104999 bytes -> 1486426 bytes

/home/testuser/image2.jpg
2048x1365 -> 1152x768
224642 bytes -> 31421 bytes

/home/testuser/Pictures/image3.png
1920x1080 -> 1365x768
2811155 bytes -> 1657474 bytes

/home/testuser/Downloads/image4
2048x1365 -> 1152x768
224642 bytes -> 31421 bytes

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

imgp -x 75 -w ~/image.jpg
/home/testuser/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...

./image1.jpg
1366x911 -> 800x534
69022 bytes -> 35123 bytes

./image2.jpg
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 FOSSLinux.com. 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. I 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!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,647FansLike
360FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

5 Ways to Open a Terminal in Ubuntu

Even though Ubuntu supports many applications with amazing Graphical User Interfaces (GUI), there are always reasons why users prefer using the Terminal to perform different tasks.

How to install Wine on Fedora Workstation

Linux distributions are becoming more and more popular every day, and Fedora Workstation is not left behind. This popularity brings forth the need to run Windows applications on Linux distros like Fedora. Windows has quite some excellent Software that is not available for Linux.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

Test drive a Linux distro online before you hate it

Enter DistroTest.net, a website that allows Linux users to test various distros online, without downloading the ISO or installing the distro. With DistroTest.net, you can check a distro with no muss, no fuss.

What’s New in Ubuntu 20.04 LTS “Focal Fossa”

Ubuntu 20.04 LTS is out now! This is the successor to Ubuntu 18.04, which was released in April 2018 and still has three years of official support left. Code-named Focal Fossa, the new edition has all the bells and whistles included in it, making it one of the best Ubuntu releases yet. Let's find out more.

7 Best Ways to Kill Unresponsive Programs in Linux

For dealing with a frozen app or desktop, you can't use the CTRL+ALT+DEL in Linux system. Instead, there are powerful alternatives that come in handy in frustrating situations. We pick the best methods available for you.

VIDEO: MX Linux 19 Features and Desktop Tour

MX Linux is a Linux distribution based on Debian stable and using core antiX components. The distributions MX Tools is very popular among users and combined with other several ready-to-use tools, it is great for users who prefer to tweak their distro to their liking. In this video, we will take you through the features tour showing casing MX Linux 19.