imgd: multiprocessing image resizer and rotator

cool_penguin_smallNautilus Image Converter is a popular extension among Ubuntu users to batch resize and rotate images. While it’s handy, it’s tied to the Nautilus file manager and is not available for users who use other flavours of Ubuntu e.g. Xubuntu or Lubuntu. imgd (read imaged) is a multiprocessing command-line alternative written in Python3. It uses the PIL (Pillow) library and has many more additional features.

Nautilus Image Converter uses a roundabout mechanism to do what it does. It is a GTK+ front-end to a shared library. This library internally calls the convert utility from ImageMagick (which is again a heavy package) with the parameters passed by the user. The convert utility calls ImageMagick library APIs and does the job of resize or rotation.

imgd, on the other hand, depends only on the Python3 PIL imaging library. To share an example of its performance: imgd could resize 8823 images (~4.5GB in size) of mixed resolutions (high to regular) stored in an external USB 2.0 hard disk at an adaptive resolution of 1366×1000 in around 8 minutes. The resulting size was 897MB (~ 20%).

By default imgd resizes images to the same resolution as Nautilus. However, it is powered with an additional adaptive resize algorithm that resizes the images to a resolution which fits the specified resolution better. For example, if an image has a resolution of 2048×1365 and is being resized to 1366×768:

  • In regular mode (default, same as Nautilus Image Converter), output image resolution will be 1152×768.
  • In adaptive mode, output image resolution will be 1366×910 (making the resulting image a better fit at a higher resolution for laptop monitors with a resolution of 1366×768).

imgd has a lot of additional perks as you’ll see in the features below.

Features

  • resize by percentage or resolution
  • rotate clockwise by specified angle
  • adaptive resize considering orientation
  • brute force to a resolution
  • optimize images to save more space
  • convert PNG to JPEG
  • erase exif metadata
  • force smaller to larger resize
  • process directories recursively
  • overwrite source image option
  • include hidden files
  • minimal dependencies

Installation

To install imgd on Ubuntu, download the Ubuntu family package from the releases page and run:

$ sudo apt-get install python3-pil
$ sudo dpkg -i imgd_version_all.deb

Usage

The options are quite self-explanatory:

$ imgd -h
  -h, --help            show this help message and exit
  -s %, --scale %       scale image by percentage
  -x HxV, --res HxV     output resolution in HxV representation
  -o deg, --rotate deg  rotate clockwise by specified angle
  -a, --adapt           adapt to resolution by orientation [default: off]
  -c, --convert         convert PNG to JPG format [default: off]
  -d, --dot             include hidden files (on Linux) [default: off]
  -e, --eraseexif       erase exif metadata [default: off]
  -f, --force           force to exact specified resolution [default: off]
  -i, --processimgd     re-process generated files. * RISKY: refer to docs
  -n, --enlarge         enlarge smaller images [default: off]
  -p, --optimize        optimize the output images [default: off]
  -q, --quiet           operate silently [default: verbose]
  -r, --recursive       process directories recursively [default: off]
  -w, --overwrite       overwrite source images [default: off]
  -z, --debug           enable debug logs [default: off]

Both the manpage and online readme has examples of imgd use cases. It can do a lot more than that though.

On GitHub: imgd

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s