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
Typesheet is a tiny Python script for creating transparent PNG spritesheets from TrueType (.ttf) fonts.

typesheet typesheet is a tiny Python script for creating transparent PNG spritesheets from TrueType (.ttf) fonts. I made it because I couldn't find an

Grayson Chao 12 Dec 23, 2022
Image Compression GUI APP Python: PyQt5

Image Compression GUI APP Image Compression GUI APP Python: PyQt5 Use : f5 or debug or simply run it on your ids(vscode , pycham, anaconda etc.) socia

Sourabh Dhalia 1 May 21, 2022
OctoPrint is the snappy web interface for your 3D printer!

OctoPrint OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software and released under the GNU Affero Genera

OctoPrint 7.1k Jan 03, 2023
Generates images of calendar month tables and can paste them onto suitable photos.

📆 calendizer README Generates images of calendar month tables and can paste them onto suitable photos. A quick way to make your own calendar for prin

Sean Ryan 2 Dec 14, 2022
Steganography Image/Data Injector.

Byte Steganography Image/Data Injector. For artists or people to inject their own print/data into their images. TODO Add more file formats to support.

Ori 4 Nov 16, 2022
A linear stairs generation add-on for Blender

Linear Stairs Generator Table of Contents Installation Usage Screenshots Important Notes Requirements Blender 3.0 or newer. Installation: Download a z

Elhanan Flesch 4 May 17, 2022
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
Hello, this project is an example of how to generate a QR Code using python 😁

Hello, this project is an example of how to generate a QR Code using python 😁

Davi Antonaji 2 Oct 12, 2021
This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character.

Room Formatter This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character. There is cur

Thomas Landstra 1 Nov 13, 2021
Combinatorial image generator for generative NFT art.

ImageGen Stitches multiple image layers together into one image. Run usage: stitch.py [-h] backgrounds_dir dinos_dir traits_dir texture_file

Dinosols NFT 19 Sep 16, 2022
Blue noise image stippling in Processing (requires GPU)

Blue noise image stippling in Processing (requires GPU)

Mike Wong 141 Oct 09, 2022
Python Image Optimizer Script

Image-Optimizer Download and Install git clone https://github.com/stefankumpan/Image-Optimizer-Script.git cd Image-Optimizer-Script pip install -r req

Stefan Kumpan 0 Jul 15, 2021
A simple Streamlit Component to compare images in Streamlit apps. It integrates Knightlab's JuxtaposeJS

streamlit-image-juxtapose A simple Streamlit Component to compare images in Streamlit apps using Knightlab's JuxtaposeJS. The images are saved to the

Robin 30 Dec 31, 2022
BeeRef — A Simple Reference Image Viewer

BeeRef — A Simple Reference Image Viewer BeeRef lets you quickly arrange your reference images and view them while you create. Its minimal interface i

Rebecca 245 Dec 25, 2022
A warping based image translation model focusing on upper body synthesis.

Pose2Img Upper body image synthesis from skeleton(Keypoints). Sub module in the ICCV-2021 paper "Speech Drives Templates: Co-Speech Gesture Synthesis

zhiyh 15 Nov 10, 2022
This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specialized data structure called VP-Tree which makes searching an image on a dataset of 100Ks almost instantanious

Offline Reverse Image Search Overview This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specia

53 Nov 15, 2022
Python library that finds the size / type of an image given its URI by fetching as little as needed

FastImage This is an implementation of the excellent Ruby library FastImage - but for Python. FastImage finds the size or type of an image given its u

Brian Muller 28 Mar 01, 2022
starfish is a Python library for processing images of image-based spatial transcriptomics.

starfish: scalable pipelines for image-based transcriptomics starfish is a Python library for processing images of image-based spatial transcriptomics

199 Dec 08, 2022
An async Python library to automate solving ReCAPTCHA v2 by audio using Playwright.

Playwright nonoCAPTCHA An async Python library to automate solving ReCAPTCHA v2 by audio using Playwright. Disclaimer This project is for educational

Michael Mooney 69 Dec 28, 2022
An application that maps an image of a LaTeX math equation to LaTeX code.

Convert images of LaTex math equations into LaTex code.

1.3k Jan 06, 2023