Fast batch image resizer and rotator for JPEG and PNG images.

Overview

imgp

Latest release Availability PyPI Build Status License

imgp_asciicast

Watch imgp resize a directory of images in lightning speed!

imgp is a command line image resizer and rotator for JPEG and PNG images. It can resize (or thumbnail) and rotate thousands of images in a go, at lightning speed, while saving significantly on storage.

Powered by multiprocessing, SIMD parallelism (thanks to the Pillow-SIMD library), an intelligent adaptive algorithm, recursive operations, shell completion scripts, EXIF preservation (and more), imgp is a very flexible utility with well-documented easy to use options.

imgp intends to be a stronger replacement of the Nautilus Image Converter extension, not tied to any file manager and way faster. On desktop environments (like Xfce or LxQt) which do not integrate Nautilus, imgp will save your day. File manager nnn provides a script to batch resize images with imgp.

Table of Contents

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
  • limit processing by minimum image size
  • convert PNG to JPEG
  • erase exif metadata
  • specify output JPEG image quality
  • force smaller to larger resize
  • process directories recursively
  • overwrite source image option
  • completion scripts for bash, fish, zsh
  • minimal dependencies

Adaptive mode

  • If the specified and image orientations are same [(H >= V and h > v) or (H < V and h < v)], the image is resized with the longer specified side as reference.
  • In case of cross orientation [(H >= V and h <= v) or (H < V and h >= v)], the image is resized with the shorter specified side as reference. Same as non-adaptive.

For example, if an image has a resolution of 2048x1365 and is being resized to 1366x768:

  • In regular mode (default), output image resolution will be 1152x768
  • In adaptive mode, output image resolution will be 1366x910

Performance

imgp could resize 8823 images (approx. 4.5GB in size) of mixed resolutions (high to regular) stored in a USB 2.0 external hard disk at an adaptive resolution of 1366x1000 in around 8 minutes. The resulting size was 897MB (approx. 20%).

imgp uses Python PIL/Pillow library. Nautilus Image Converter calls the convert utility from ImageMagick. For a comparative benchmark, head here.

Installation

Dependencies

imgp requires Python 3.6 or later.

To install PIL library on Ubuntu, run:

$ sudo apt-get install python3-pil

or, using pip3:

$ sudo pip3 install pillow

pillow can be replaced by pillow-simd on SIMD processors.

From a package manager

Install imgp from your package manager. If the version available is dated try an alternative installation method.

Packaging status (expand)


Packaging status

Unlisted packagers:


Homebrew TAP (brew install jarun/imgp/imgp)
PyPI (pip3 install imgp)
Source Mage (cast imgp)

Release packages

Packages for Arch Linux, CentOS, Debian, Fedora, openSUSE Leap and Ubuntu are available with the latest stable release.

From source

If you have git installed, clone this repository. Otherwise download the latest stable release or development version (risky).

Install to default location (/usr/local):

$ sudo make install

To remove, run:

$ sudo make uninstall

PREFIX is supported, in case you want to install to a different location.

Running standalone

imgp is a standalone utility. From the containing directory, run:

$ ./imgp

Shell completion

Shell completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of auto-completion/. Please refer to your shell's manual for installation instructions.

Usage

cmdline options

usage: imgp [-h] [-x res] [-o deg] [-a] [-c] [-e] [-f] [-H] [-i] [-k] [-m] [-M res]
            [-n] [-N] [-O] [-P] [-q N] [-r] [-s byte] [-w] [-d] [PATH [PATH ...]]

Resize, rotate JPEG and PNG images.

positional arguments:
  PATH                  source file or dir [default: current dir]

optional arguments:
  -h, --help            show this help message and exit
  -x res, --res res     output resolution in HxV or percentage
  -o deg, --rotate deg  rotate clockwise by angle (in degrees)
  -a, --adapt           adapt to resolution by orientation [default: off]
  -c, --convert         convert PNG to JPG format [default: off]
  -e, --eraseexif       erase exif metadata [default: off]
  -f, --force           force to exact specified resolution [default: off]
  -H, --hidden          include hidden (dot) files [default: off]
  -i, --includeimgp     re-process _IMGP files. * RISKY: refer to docs
  -k, --keep            skip (honors -c or --pr) images matching specified
                        H or V or --res=100 [default: off]
  -m, --mute            operate silently [default: informative]
  -M res, --minres res  min resolution in HxV or percentage of --res to resize
  -n, --enlarge         enlarge smaller images [default: off]
  -N, --nearest         use nearest neighbour interpolation for PNG [default: antialias]
  -O, --optimize        optimize the output images [default: off]
  -P, --progressive     save JPEG images as progressive [default: off]
  -q N, --quality N     quality factor (N=1-95, JPEG only) [default: 75]
  -r, --recurse         process non-symbolic dirs recursively [default: off]
  -s byte, --size byte  minimum size to process an image [default: 1024]
  -w, --overwrite       overwrite source images [default: off]
  -d, --debug           enable debug logs [default: off]

Operational notes

  • Multiple files and directories can be specified as source. If PATH is omitted, the current directory is processed.
  • Output image names are appended with _IMGP if --overwrite option is not used. By default _IMGP files are not processed. Doing so may lead to potential race conditions when --overwrite option is used.
  • PNG files with lower target hres/vres are not converted (even if --convert is used). Run imgp --convert (*.png) separately to convert those.
  • Resize and rotate are lossy operations. For additional reductions in size try --optimize and --eraseexif options.
  • Option --optimize is slower, the encoder makes an extra pass over the image in order to select optimal encoder settings.
  • Progressive JPEG images are saved as progressive.

Examples

  1. 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
    
  2. 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
    
  3. Rotate an image clockwise by 90 degrees:

    $ imgp -o 90  ~/image.jpg
    120968 bytes -> 72038 bytes
    
  4. Adapt the images in the current directory to 1366x1000 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
    
  5. 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
    
  6. Process images greater than 50KiB only:

    $ imgp -wrackx 1366x1000 -s 51200
    
  7. Generate a 64px adapative thumbnail of the last modified file in the current dir:

    #!/usr/bin/env sh
    
    thumb64 ()
    {
        pop=$(ls -1t | head -1)
        imgp -acx 64x64 "$pop"
    }
    

Developers

  1. Copyright © 2016-2021 Arun Prakash Jana
  2. Ananya Jana
Comments
  • Progressive jpeg

    Progressive jpeg

    More of a question than an issue.. I generate and upload lots of 5K images to a web gallery and would like to present them progressively. I use imgp and love it's speed but I can't find any reference to progressive mode. Is it on the road map? Thanks Sdack

    opened by motioncircus 52
  • Upload imgd to pypi

    Upload imgd to pypi

    First of all, thanks for making such an convenient tool for image processing. I noticed that imgd is not on pypi yet, why not making it so? Thus people could using pip install imgd to install it directly.

    If you approve this, I can send a pull request of the essential code to register imgd to pypi.

    opened by reorx 18
  • No PNG to JPG conversion on MacOs

    No PNG to JPG conversion on MacOs

    Hi Arun! First of all thank you for such a great tool!

    I tried to install it on Sierra and ran into the PNG to JPG conversion problem. Everything works as it has to but it simply ignores the PNG files. I have correctly installed python 3.6.1, Pillow and made the make installation as you instructed. All the paths look right, imagemagick is also present. I used different combination of arguments but no luck.

    I know you have no MacOs mention in readme file but maybe you can make a Brew package so we can use all options on Mac.

    Also I've notice significant colour saturation change, is there any option to manually set the parameters?

    opened by pavelberger 7
  • How to resize all image but ignore images with leass than 200 dimentionals

    How to resize all image but ignore images with leass than 200 dimentionals

    How to resize all image but ignore image with less than 200 dimensional?

    I try:

    imgp -wrpecx 50 -k 300 images

    But it still convert an image from 194x260 to 96x130

    I want to skip some images like this.

    opened by omidraha 6
  • non-retention of some EXIF metadata

    non-retention of some EXIF metadata

    • Fresh install of Ubuntu 19.04 (actually, running off live USB)
    • Installed version 2.6 via apt-get install imgp after checking the “Community-maintained free and open-sourced software (universe)” box in Software & Updates.
    • Ran imgp -x 1200x800 -r -z /path/to/input/ (The -z switch was useless as I do not konw where the log went.)
    • Got reduced size versions blazingly fast (yay!)
    • BUT quite a few of the EXIF fields were lost.
    • See attached files for list of original EXIF fields and those in resulting _IMGP file, and a diff -y between them that has been modified to be easier to read.
    • Also ran quick test running v. 2.6 from the repository with ./GITCLONED_imgp/imgp -x 1200x800 -r /path/to/input/; only checked “Attribution Name” field, but it was missing. I presume the rest were, too.

    TSTJPEG_orig_exif_fields.txt TSTJPEG_IMGP_exif_fields.txt TSTJPEG_exif_field_diff.txt

    opened by sydb 5
  • image.jpg: not JPEG or PNG image (when it actually is)

    image.jpg: not JPEG or PNG image (when it actually is)

    Hi, While looking for a fast image resizer for a low power project, I found and installed your awesome tool on a RaspberryPi ZeroW machine running the latest version of Raspbian (Stretch).

    Finding the error mentioned in the subject line, while testing an IMGP resize on one of my images, I downloaded a couple of alternative images from the Internet as comparison tests. One PNG and one JPEG picked at random. IMGP worked fine on those files.

    The unidentifiable jpg of mine (attached below) was shot by a Canon Powershot camera and transferred to the machine using CHDK-PTP (Canon Hackers Development Kit)

    I attach the image in the hope that it may shed some light on the issue. Thanks

    still-2017_11_09___09_57

    duplicate 
    opened by motioncircus 5
  • Adding Fast Seam Carving Reducing Size Feature

    Adding Fast Seam Carving Reducing Size Feature

    Adding Fast Seam Carving. Seam Carving is a method of resizing an image that is in a sense context-aware. Fast Seam Carving is an optimized method with the utilization of Gaussian Pyramids. Adding this as an additional feature also can make it a separate function if required.

    opened by rohansh500 4
  • Converting images to max 350KB

    Converting images to max 350KB

    I have a folder with images of different size and try to convert the images that are greater then 350KB into something around 350KB. I know I can't set output file size but I tried with specifying the min file size before processing and to limit the resolution in order to get to my requirements. The problem is that I get the following output if I try to run it in the image folder:

    imgp -akx 1600 -s 358400
    > use --enlarge is to scale > 100%
    
    opened by jwillmer 4
  • Some images color saturation is reduced after running the image through imgp.

    Some images color saturation is reduced after running the image through imgp.

    I was using imgp to resize a bunch of product images, and found that one or two lost it's luster (i.e. the color saturation was reduced). I've included an example of the original and new image - curious if there's any improvement to the tool that could solve for this - or if there was a setting I missed.

    140174_campaign copy_imgp 140174_campaign copy

    opened by jgoslow 4
  • cannot convert PNG files in palette mode')

    cannot convert PNG files in palette mode')

    Hi,

    When i convert many files in a folder, i got error message:"cannot convert PNG files in palette mode". I found it is because my png file need to be converted. Can we add some function to fix it ?

    Thanks.

    opened by jacknion 3
  • Picture example of the adaptive mode

    Picture example of the adaptive mode

    The adaptive mode is a cool feature and is documented well in the README file. But as they say, a picture is worth thousands of words. I think it might be clearer for readers if there are corresponding picture examples to recognize what will happen. Just a suggestion, might be a "Good First Issue".

    opened by liwt31 3
Releases(v2.8)
Owner
Terminator X
Blending the terminal in a GUI world.
Terminator X
Vignette is a Python library to create and manage thumbnails following the FreeDesktop standard.

Vignette Vignette is a Python library to create and manage thumbnails following the FreeDesktop standard. Thumbnails are stored in a shared directory

3 Feb 06, 2022
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

Thumbor (by @globocom) 9.3k Dec 31, 2022
A Python3 library to generate dynamic SVGs

The Python library for generating dynamic SVGs using Python3

1 Dec 23, 2021
Fast batch image resizer and rotator for JPEG and PNG images.

imgp is a command line image resizer and rotator for JPEG and PNG images.

Terminator X 921 Dec 25, 2022
A Python package implementing various HDRI / Radiance image processing algorithms.

Colour - HDRI A Python package implementing various HDRI / Radiance image processing algorithms. It is open source and freely available under the New

colour-science 111 Dec 06, 2022
PyGram Instagram-like image filters.

PyGram Instagram-like image filters. Usage First, import the client: from filters import * Instanciate a filter and apply it: f = Nashville("image.jp

Ajay Kumar Nagaraj 102 Feb 21, 2022
A Icon Maker GUI Made - Convert your image into icon ( .ico format ).

Icon-Maker-GUI A Icon Maker GUI Made Using Python 3.9.0 . It will take any image and convert it to ICO file, for web site favicon or Windows applicati

Insanecodes 12 Dec 15, 2021
A python script for extracting/removing exif data from images by @AbirHasan2005

Image-Exif A Python script for extracting exif metadata from images. How to use? Using this script you can extract exif data from image and save in .c

Abir Hasan 13 Dec 16, 2022
Napari simpleitk image processing

napari-simpleitk-image-processing (n-SimpleITK) Process images using SimpleITK in napari Usage Filters of this napari plugin can be found in the Tools

Robert Haase 11 Dec 19, 2022
Convert a DOS Punk image to text

DOS Punk Text Inspired by MAX CAPACITY's DOS Punks & the amazing DOS Punk community. DOS Punk Text is a Python 3 script that renders a DOS Punk image

4 Jan 13, 2022
A Robust Avatar Generator with a huge number of templates

CoolAvatars Welcome to this repository of CoolAvatars. Using this project, you can generate cool avatars not only from the samples present in my image

RAVI PRAKASH 5 Oct 12, 2021
A Gtk based Image Selector with Preview

gtk-image-selector This is an attempt to restore Gtk Image Chooser "lost functionality": displaying an image preview when selecting images... This is

Spiros Georgaras 2 Sep 28, 2022
Python library for ascii graphics

Python library for ascii graphics

Anton 6 Oct 20, 2021
Detecting haze image with hazer.

hazer-py Detecting haze image with hazer. What is hazer Hazer is a lib for getting "haze degree". This repository is python version of hazer: https://

Joey777210 2 Dec 27, 2021
Pnuemonia Normal detection by using XRay images.

Pnuemonia Normal detection by using XRay images. Got image datas from kaggle(link is given in sources.txt file) also normal xray images from other site (also link is given) in order to avoid data dis

Zarina 1 Feb 28, 2022
ModernGL is a python wrapper over OpenGL 3.3+ core

ModernGL is a python wrapper over OpenGL 3.3+ core that simplifies the creation of simple graphics applications like scientific simulations, games or user interface

ModernGL 1.4k Jan 01, 2023
Blender addon to generate better building models from satellite imagery.

Blender addon to generate better building models from satellite imagery.

Ivan Ereshchenko 24 Apr 14, 2022
PIX is an image processing library in JAX, for JAX.

PIX PIX is an image processing library in JAX, for JAX. Overview JAX is a library resulting from the union of Autograd and XLA for high-performance ma

DeepMind 294 Jan 08, 2023
Fixed Version Of Blender Low Poly Rock Generator For Blender 3.0.0

Blender (3.0.0) - Low Poly Rock Generator This is an addon for Blender 3.0.0 to generate low poly rocks. It was based on an addon that unfortunately h

3 Mar 24, 2022
Gallery written in Python to manage your photos

GalleryMan Gallery written in Python to manage your photos Installation

Asian Cat 24 Dec 18, 2022