<h1 align="center">imgp</h1>
<p align="center">
<a href="https://github.com/jarun/imgp/releases/latest"><img src="https://img.shields.io/github/release/jarun/imgp.svg?maxAge=600" alt="Latest release" /></a>
<a href="https://repology.org/project/imgp/versions"><img src="https://repology.org/badge/tiny-repos/imgp.svg" alt="Availability"></a>
<a href="https://pypi.org/project/imgp/"><img src="https://img.shields.io/pypi/v/imgp.svg?maxAge=600" alt="PyPI" /></a>
<a href="https://circleci.com/gh/jarun/workflows/imgp"><img src="https://img.shields.io/circleci/project/github/jarun/imgp.svg" alt="Build Status" /></a>
<a href="https://github.com/jarun/imgp/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-GPLv3-yellowgreen.svg?maxAge=2592000" alt="License" /></a>
</p>
<p align="center">
<a href="https://asciinema.org/a/88448"><img src="https://asciinema.org/a/88448.svg" alt="imgp_asciicast" width="600"/></a>
</p>
<p align="center"><i>Watch imgp resize a directory of images in lightning speed!</i></p>
`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](https://github.com/jarun/nnn) provides a script to batch resize images with `imgp`.
### Table of Contents
- [Features](#features)
- [Adaptive mode](#adaptive-mode)
- [Performance](#performance)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [From a package manager](#from-a-package-manager)
- [Release packages](#release-packages)
- [From source](#from-source)
- [Running standalone](#running-standalone)
- [Shell completion](#shell-completion)
- [Usage](#usage)
- [cmdline options](#cmdline-options)
- [Operational notes](#operational-notes)
- [Examples](#examples)
- [Developers](#developers)
### 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](https://github.com/uploadcare/pillow-simd#benchmarks).
### Installation
#### Dependencies
`imgp` requires Python 3.8 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](https://github.com/uploadcare/pillow-simd) on [SIMD](https://en.wikipedia.org/wiki/SIMD) processors.
#### From a package manager
Install `imgp` from your package manager. If the version available is dated try an alternative installation method.
<details><summary>Packaging status (expand)</summary>
<p>
<br>
<a href="https://repology.org/project/imgp/versions"><img src="https://repology.org/badge/vertical-allrepos/imgp.svg" alt="Packaging status"></a>
</p>
Unlisted packagers:
<p>
<br>
● <a href="https://github.com/jarun/homebrew-imgp">Homebrew TAP</a> (<code>brew install jarun/imgp/imgp</code>)<br>
● <a href="https://pypi.org/project/imgp/">PyPI</a> (<code>pip3 install imgp</code>)<br>
● <a href="http://codex.sourcemage.org/test/graphics/imgp/">Source Mage</a> (<code>cast imgp</code>)<br>
</p>
</details>
#### Release packages
Packages for Arch Linux, CentOS, Debian, Fedora, openSUSE Leap and Ubuntu are available with the [latest stable release](https://github.com/jarun/imgp/releases/latest).
#### From source
If you have git installed, clone this repository. Otherwise download the [latest stable release](https://github.com/jarun/imgp/releases/latest) or [development version](https://github.com/jarun/imgp/archive/master.zip) (*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/](https://github.com/jarun/imgp/blob/master/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-2023 [Arun Prakash Jana](https://github.com/jarun)
2. [Ananya Jana](https://github.com/ananyajana)
Raw data
{
"_id": null,
"home_page": "https://github.com/jarun/imgp",
"name": "imgp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "image processing resize rotate optimize",
"author": "Arun Prakash Jana",
"author_email": "engineerarun@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8a/dd/f425a947a781f2820f0fe1d5d8cf2cf4d1068553e5bb931873a60cadcaa0/imgp-2.9.tar.gz",
"platform": "any",
"description": "<h1 align=\"center\">imgp</h1>\n\n<p align=\"center\">\n<a href=\"https://github.com/jarun/imgp/releases/latest\"><img src=\"https://img.shields.io/github/release/jarun/imgp.svg?maxAge=600\" alt=\"Latest release\" /></a>\n<a href=\"https://repology.org/project/imgp/versions\"><img src=\"https://repology.org/badge/tiny-repos/imgp.svg\" alt=\"Availability\"></a>\n<a href=\"https://pypi.org/project/imgp/\"><img src=\"https://img.shields.io/pypi/v/imgp.svg?maxAge=600\" alt=\"PyPI\" /></a>\n<a href=\"https://circleci.com/gh/jarun/workflows/imgp\"><img src=\"https://img.shields.io/circleci/project/github/jarun/imgp.svg\" alt=\"Build Status\" /></a>\n<a href=\"https://github.com/jarun/imgp/blob/master/LICENSE\"><img src=\"https://img.shields.io/badge/license-GPLv3-yellowgreen.svg?maxAge=2592000\" alt=\"License\" /></a>\n</p>\n\n<p align=\"center\">\n<a href=\"https://asciinema.org/a/88448\"><img src=\"https://asciinema.org/a/88448.svg\" alt=\"imgp_asciicast\" width=\"600\"/></a>\n</p>\n\n<p align=\"center\"><i>Watch imgp resize a directory of images in lightning speed!</i></p>\n\n`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.\n\nPowered 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.\n\n`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](https://github.com/jarun/nnn) provides a script to batch resize images with `imgp`.\n\n### Table of Contents\n\n- [Features](#features)\n - [Adaptive mode](#adaptive-mode)\n- [Performance](#performance)\n- [Installation](#installation)\n - [Dependencies](#dependencies)\n - [From a package manager](#from-a-package-manager)\n - [Release packages](#release-packages)\n - [From source](#from-source)\n - [Running standalone](#running-standalone)\n- [Shell completion](#shell-completion)\n- [Usage](#usage)\n - [cmdline options](#cmdline-options)\n - [Operational notes](#operational-notes)\n- [Examples](#examples)\n- [Developers](#developers)\n\n### Features\n\n- resize by percentage or resolution\n- rotate clockwise by specified angle\n- adaptive resize considering orientation\n- brute force to a resolution\n- optimize images to save more space\n- limit processing by minimum image size\n- convert PNG to JPEG\n- erase exif metadata\n- specify output JPEG image quality\n- force smaller to larger resize\n- process directories recursively\n- overwrite source image option\n- completion scripts for bash, fish, zsh\n- minimal dependencies\n\n#### Adaptive mode\n\n- 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.\n- 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.\n\nFor example, if an image has a resolution of 2048x1365 and is being resized to 1366x768:\n\n- In regular mode (default), output image resolution will be 1152x768\n- In adaptive mode, output image resolution will be 1366x910\n\n### Performance\n\n`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%).\n\n`imgp` uses Python PIL/Pillow library. Nautilus Image Converter calls the `convert` utility from ImageMagick. For a comparative benchmark, head [here](https://github.com/uploadcare/pillow-simd#benchmarks).\n\n### Installation\n\n#### Dependencies\n\n`imgp` requires Python 3.8 or later.\n\nTo install PIL library on Ubuntu, run:\n\n $ sudo apt-get install python3-pil\n\nor, using pip3:\n\n $ sudo pip3 install pillow\n\npillow can be replaced by [pillow-simd](https://github.com/uploadcare/pillow-simd) on [SIMD](https://en.wikipedia.org/wiki/SIMD) processors.\n\n#### From a package manager\n\nInstall `imgp` from your package manager. If the version available is dated try an alternative installation method.\n\n<details><summary>Packaging status (expand)</summary>\n<p>\n<br>\n<a href=\"https://repology.org/project/imgp/versions\"><img src=\"https://repology.org/badge/vertical-allrepos/imgp.svg\" alt=\"Packaging status\"></a>\n</p>\nUnlisted packagers:\n<p>\n<br>\n\u25cf <a href=\"https://github.com/jarun/homebrew-imgp\">Homebrew TAP</a> (<code>brew install jarun/imgp/imgp</code>)<br>\n\u25cf <a href=\"https://pypi.org/project/imgp/\">PyPI</a> (<code>pip3 install imgp</code>)<br>\n\u25cf <a href=\"http://codex.sourcemage.org/test/graphics/imgp/\">Source Mage</a> (<code>cast imgp</code>)<br>\n</p>\n</details>\n\n#### Release packages\n\nPackages for Arch Linux, CentOS, Debian, Fedora, openSUSE Leap and Ubuntu are available with the [latest stable release](https://github.com/jarun/imgp/releases/latest).\n\n#### From source\n\nIf you have git installed, clone this repository. Otherwise download the [latest stable release](https://github.com/jarun/imgp/releases/latest) or [development version](https://github.com/jarun/imgp/archive/master.zip) (*risky*).\n\nInstall to default location (`/usr/local`):\n\n $ sudo make install\n\nTo remove, run:\n\n $ sudo make uninstall\n\n`PREFIX` is supported, in case you want to install to a different location.\n\n#### Running standalone\n\n`imgp` is a standalone utility. From the containing directory, run:\n\n $ ./imgp\n\n### Shell completion\n\nShell completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of [auto-completion/](https://github.com/jarun/imgp/blob/master/auto-completion). Please refer to your shell's manual for installation instructions.\n\n### Usage\n\n#### cmdline options\n\n```\nusage: imgp [-h] [-x res] [-o deg] [-a] [-c] [-e] [-f] [-H] [-i] [-k] [-m] [-M res]\n [-n] [-N] [-O] [-P] [-q N] [-r] [-s byte] [-w] [-d] [PATH [PATH ...]]\n\nResize, rotate JPEG and PNG images.\n\npositional arguments:\n PATH source file or dir [default: current dir]\n\noptional arguments:\n -h, --help show this help message and exit\n -x res, --res res output resolution in HxV or percentage\n -o deg, --rotate deg rotate clockwise by angle (in degrees)\n -a, --adapt adapt to resolution by orientation [default: off]\n -c, --convert convert PNG to JPG format [default: off]\n -e, --eraseexif erase exif metadata [default: off]\n -f, --force force to exact specified resolution [default: off]\n -H, --hidden include hidden (dot) files [default: off]\n -i, --includeimgp re-process _IMGP files. * RISKY: refer to docs\n -k, --keep skip (honors -c or --pr) images matching specified\n H or V or --res=100 [default: off]\n -m, --mute operate silently [default: informative]\n -M res, --minres res min resolution in HxV or percentage of --res to resize\n -n, --enlarge enlarge smaller images [default: off]\n -N, --nearest use nearest neighbour interpolation for PNG [default: antialias]\n -O, --optimize optimize the output images [default: off]\n -P, --progressive save JPEG images as progressive [default: off]\n -q N, --quality N quality factor (N=1-95, JPEG only) [default: 75]\n -r, --recurse process non-symbolic dirs recursively [default: off]\n -s byte, --size byte minimum size to process an image [default: 1024]\n -w, --overwrite overwrite source images [default: off]\n -d, --debug enable debug logs [default: off]\n```\n\n#### Operational notes\n\n- Multiple files and directories can be specified as source. If `PATH` is omitted, the current directory is processed.\n- 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.\n- PNG files with lower target hres/vres are not converted (even if `--convert` is used). Run `imgp --convert (*.png)` separately to convert those.\n- Resize and rotate are lossy operations. For additional reductions in size try `--optimize` and `--eraseexif` options.\n- Option `--optimize` is slower, the encoder makes an extra pass over the image in order to select optimal encoder settings.\n- Progressive JPEG images are saved as progressive.\n\n### Examples\n\n1. Convert some images and directories:\n\n $ imgp -x 1366x768 ~/ ~/Pictures/image3.png ~/Downloads/\n /home/testuser/image1.png\n 3840x2160 -> 1365x768\n 11104999 bytes -> 1486426 bytes\n\n /home/testuser/image2.jpg\n 2048x1365 -> 1152x768\n 224642 bytes -> 31421 bytes\n\n /home/testuser/Pictures/image3.png\n 1920x1080 -> 1365x768\n 2811155 bytes -> 1657474 bytes\n\n /home/testuser/Downloads/image4\n 2048x1365 -> 1152x768\n 224642 bytes -> 31421 bytes\n\n2. Scale an image by 75% and overwrite the source image:\n\n $ imgp -x 75 -w ~/image.jpg\n /home/testuser/image.jpg\n 1366x767 -> 1025x575\n 120968 bytes -> 45040 bytes\n\n3. Rotate an image clockwise by 90 degrees:\n\n $ imgp -o 90 ~/image.jpg\n 120968 bytes -> 72038 bytes\n\n4. 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.\n\n $ imgp -x 1366x1000 -wrack\n\n5. Set hres=800 and adapt vres maintaining the ratio.\n\n $ imgp -x 800x0\n Source omitted. Processing current directory...\n\n ./image1.jpg\n 1366x911 -> 800x534\n 69022 bytes -> 35123 bytes\n\n ./image2.jpg\n 1050x1400 -> 800x1067\n 458092 bytes -> 78089 bytes\n\n6. Process images greater than 50KiB only:\n\n $ imgp -wrackx 1366x1000 -s 51200\n\n7. Generate a 64px adapative thumbnail of the last modified file in the current dir:\n\n #!/usr/bin/env sh\n\n thumb64 ()\n {\n pop=$(ls -1t | head -1)\n imgp -acx 64x64 \"$pop\"\n }\n\n### Developers\n\n1. Copyright \u00a9 2016-2023 [Arun Prakash Jana](https://github.com/jarun)\n2. [Ananya Jana](https://github.com/ananyajana)\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "High-performance CLI batch image resizer & rotator",
"version": "2.9",
"project_urls": {
"Homepage": "https://github.com/jarun/imgp"
},
"split_keywords": [
"image",
"processing",
"resize",
"rotate",
"optimize"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cedee283fa9c56775a55dd338d3dba33186617ec486c90b7de509d8e81c640dd",
"md5": "075a0e72b4b73057f8991a24991f2df7",
"sha256": "8b49203dfec731e292c5ac20bffec807473575e31b1dd32d7a786ccd46bda5d3"
},
"downloads": -1,
"filename": "imgp-2.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "075a0e72b4b73057f8991a24991f2df7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 23524,
"upload_time": "2023-09-10T03:51:24",
"upload_time_iso_8601": "2023-09-10T03:51:24.255381Z",
"url": "https://files.pythonhosted.org/packages/ce/de/e283fa9c56775a55dd338d3dba33186617ec486c90b7de509d8e81c640dd/imgp-2.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8addf425a947a781f2820f0fe1d5d8cf2cf4d1068553e5bb931873a60cadcaa0",
"md5": "bc921b0815840f8779c333c3ed2df715",
"sha256": "38f2be11b27d7b56c13e7c56386cb6cb144d822fa6f2cfd3938398ee487e6d2b"
},
"downloads": -1,
"filename": "imgp-2.9.tar.gz",
"has_sig": false,
"md5_digest": "bc921b0815840f8779c333c3ed2df715",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 24875,
"upload_time": "2023-09-10T03:51:27",
"upload_time_iso_8601": "2023-09-10T03:51:27.105931Z",
"url": "https://files.pythonhosted.org/packages/8a/dd/f425a947a781f2820f0fe1d5d8cf2cf4d1068553e5bb931873a60cadcaa0/imgp-2.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-10 03:51:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jarun",
"github_project": "imgp",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"circle": true,
"lcname": "imgp"
}