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
Png-to-stl - Converts PNG and text to SVG, and then extrudes that based on parameters

have ansible installed locally run ansible-playbook setup_application.yml this sets up directories, installs system packages, and sets up python envir

null 1 Jan 3, 2022
MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images

MetaStalk About MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images, which are tested. More forma

Cyb3r Jak3 1 Jul 5, 2021
Png2Jpg tool will help you convert from png image format to jpg images format.

PNG 2 JPG All codes assume running from root directory. Please update the sys path at the beginning of the codes before running. Over View Png2Jpg too

Nguyễn Trường Lâu 2 Dec 27, 2021
Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

null 1 Jan 16, 2022
Convert the SVG code to PNG and replace the line by a call to the image in markdown

Convert the SVG code to PNG and replace the line by a call to the image in markdown

null 6 Sep 6, 2022
Transfers a image file(.png) to an Excel file(.xlsx)

Transfers a image file(.png) to an Excel file(.xlsx)

Junu Kwon 7 Feb 11, 2022
LGVL helper script to batch and convert with lvgl offline image converter

script to batch and convert with lvgl offline image converter

Yohann 1 Oct 5, 2022
With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen

Oraxen-item-to-yml With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen How to use Install the

Akex 1 Dec 29, 2021
An API that renders HTML/CSS content to PNG using Chromium

html_png An API that renders HTML/CSS content to PNG using Chromium Disclaimer I am not responsible if you happen to make your own instance of this AP

null 10 Aug 8, 2022
A simple programme for converting url into a qr code (.png file)

QrTk A simple lightweight programme for converting url into a qr code (.png file) Pre-Requisites Before installing the programme , you need to run the

Juss Patel 4 Nov 8, 2021
A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos.

font2png A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos. To use from command line it expects python3 to be at /

Rich Elmes 3 Dec 22, 2021
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
A proof-of-concept implementation of a parallel-decodable PNG format

mtpng A parallelized PNG encoder in Rust by Brion Vibber [email protected] Background Compressing PNG files is a relatively slow operation at large imag

Brion Vibber 193 Dec 16, 2022
Seaborn-image is a Python image visualization library based on matplotlib and provides a high-level API to draw attractive and informative images quickly and effectively.

seaborn-image: image data visualization Description Seaborn-image is a Python image visualization library based on matplotlib and provides a high-leve

null 48 Jan 5, 2023
Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Python

AICSImageIO Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python Features Supports reading metadata and imaging

Allen Institute for Cell Science - Modeling 137 Dec 14, 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

null 53 Nov 15, 2022
Fast Image Retrieval is an open source image retrieval framework

Fast Image Retrieval is an open source image retrieval framework release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This framework implements most of the major binary hashing methods, together with both popular backbone networks and public datasets.

CISiP Lab 39 Nov 25, 2022
Fast Image Retrieval (FIRe) is an open source image retrieval project

Fast Image Retrieval (FIRe) is an open source image retrieval project release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This project implements most of the major binary hashing methods to date, together with different popular backbone networks and public datasets.

CISiP Lab 39 Nov 25, 2022
missing-pixel-filler is a python package that, given images that may contain missing data regions (like satellite imagery with swath gaps), returns these images with the regions filled.

Missing Pixel Filler This is the official code repository for the Missing Pixel Filler by SpaceML. missing-pixel-filler is a python package that, give

SpaceML 11 Jul 19, 2022