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
Napari 3D Ortho Viewer - an ortho viewer for napari for 3D images

napari-3d-ortho-viewer Napari 3D Ortho Viewer - an ortho viewer for napari for 3D images This napari plugin was generated with Cookiecutter using @nap

niklas netter 5 Nov 28, 2022
A pure python implementation of the GIMP XCF image format. Use this to interact with GIMP image formats

Pure Python implementation of the GIMP image formats (.xcf projects as well as brushes, patterns, etc)

FHPyhtonUtils 8 Dec 30, 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
A scalable implementation of WobblyStitcher for 3D microscopy images

WobblyStitcher Introduction A scalable implementation of WobblyStitcher Dependencies $ python -m pip install numpy scikit-image Visualization ImageJ

CSE Lab, ETH Zurich 7 Jul 25, 2022
Image Processing - Make noise images clean

影像處理-影像降躁化(去躁化) (Image Processing - Make Noise Images Clean) 得力於電腦效能的大幅提升以及GPU的平行運算架構,讓我們能夠更快速且有效地訓練AI,並將AI技術應用於不同領域。本篇將帶給大家的是 「將深度學習應用於影像處理中的影像降躁化 」,

2 Aug 04, 2022
Script that organizes the Google Takeout archive into one big chronological folder

Script that organizes the Google Takeout archive into one big chronological folder

Mateusz Soszyński 1.6k Jan 09, 2023
A functional and efficient python implementation of the 3D version of Maxwell's equations

py-maxwell-fdfd Solving Maxwell's equations via A python implementation of the 3D curl-curl E-field equations. This code contains additional work to e

Nathan Zhao 12 Dec 11, 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
Music Thumbnail Maker

Music Thumbnail Installing pip install TMFrame

krypton 4 Jan 28, 2022
Forza painter app with python

forza-painter Discord: A-Dawg#0001 (AE) Supports: Forza Horizon 5 Offically (OTHER v1.405.2.0, MS STORE v3.414.967.0, STEAM v1.414.967.0) Unofficially

320 Dec 31, 2022
CropImage is a simple toolkit for image cropping, detecting and cropping main body from pictures.

CropImage is a simple toolkit for image cropping, detecting and cropping main body from pictures. Support face and saliency detection.

Haofan Wang 15 Dec 22, 2022
Hide sensitive information in images

Data-Preserved Script allowing to blur the most sensitive information on images. Prerequisites Before you begin, ensure you have met the following req

2 Dec 01, 2021
Polyfoto - Create image mosaics.

Polyfoto Create image mosaics. Showcase "Before and After Science" by Brian Eno "Scott 3" by Scott Walker Installation Clone this repository to your l

Shane Drabing 149 Dec 25, 2022
Remove Background from Image With Python

Install Library pypi $ pip3 install xremovebg

krypton 4 May 26, 2022
Craft PNG files that appear completely different in Apple software

Ambiguous PNG Packer Craft PNG files that appear completely different in Apple software

David Buchanan 1k Dec 29, 2022
Sample data for the napari image viewer.

napari-demo-data Sample data for the napari image viewer. This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugi

Genevieve Buckley 1 Nov 08, 2021
sK1 2.0 cross-platform vector graphics editor

sK1 2.0 sK1 2.0 is a cross-platform open source vector graphics editor similar to CorelDRAW, Adobe Illustrator, or Freehand. sK1 is oriented for prepr

sK1 Project 238 Dec 04, 2022
HtmlWebShot - A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features.

A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features

Danish 24 Dec 14, 2022
A QR Code encode and decode python module

A QR Code encode and decode python module

Fayas Noushad 4 Feb 10, 2022
Create a static HTML/CSS image gallery from a bunch of images.

gallerize Create a static HTML/CSS image gallery from a bunch of images.

Jochen Kupperschmidt 19 Aug 21, 2022