Skip to main content

A little command-line interface (CLI) utility

Project description

Optimize Images Github commits (since latest release)

A command-line interface (CLI) utility written in pure Python to help you reduce the file size of images.

This application is intended to be pure Python, with no special dependencies besides Pillow, therefore ensuring compatibility with a wide range of systems, including iPhones and iPads running Pythonista 3. If you don't have the need for such a strict dependency management, you will probably be better served by any several other image optimization utilities that are based on some well known external binaries.

optimize-images_screenshot

Documentation

Installation and dependencies:

To install and run this application, you need to have a working Python 3.6+ installation. We try to keep the external dependencies at a minimum, in order to keep compatibility with different platforms, including Pythonista on iOS. At this moment, we require:

  • Pillow>=5.1.0
  • piexif==1.0.13

The easiest way to install it in a single step, including any dependencies, is by using this command:

pip3 install pillow optimize-images

However, if you are on a Mac with Python 3.6 and macOS X 10.11 El Capitan or earlier, you should use Pillow 5.0.0 instead (use instead: pip3 install pillow==5.0.0 optimize-images). In case you have already migrated to Python 3.7, you should be fine with Pillow 5.1.0 or later.

You can also use this application on iOS, using an called Pythonista 3 (which is, among other things, a very nice environment for developing and/or running pure Python applications on iOS). Please check the detailed install procedure full in the user documentation.

How to use

The most simple form of usage is to type a simple command in the shell, passing the path to an image or a folder containing images as an argument. The optional -nr or --no-recursion switch argument tells the application not to scan recursively through the subdirectories.

By default, this utility applies lossy compression to JPEG files using a quality setting of 80% (by Pillow's scale), removes any EXIF metadata, tries to optimize each encoder's settings for maximum space reduction and applies the maximum ZLIB compression on PNG.

You must explicitly pass it a path to the source image file or to the directory containing the image files to be processed. By default, it will scan recursively through all subfolders and process any images found using the default or user-provided settings, replacing each original file by its processed version if its file size is smaller than the original.

If no space savings were achieved for a given file, the original version will be kept instead.

There are many other features and command-line options, like downsizing, keeping EXIF data, color palete reduction, PNG to JPEG conversion. Please check the docs for further information.

DISCLAIMER:
Please note that the operation is done DESTRUCTIVELY, by replacing the original files with the processed ones. You definitely should duplicate the source file or folder before using this utility, in order to be able to recover any eventual damaged files or any resulting images that don't have the desired quality.

Basic usage

Try to optimize a single image file:

optimize-images filename.jpg

Try to optimize all image files in current working directory and all of its subdirectories:

optimize-images ./

Try to optimize all image files in current working directory, without recursion:

optimize-images -nr ./
optimize-images --no-recursion ./

Getting help

To check the list of available options and their usage, you just need to use one of the following commands:

optimize-images -h
optimize-images --help

Did you find a bug or do you have a suggestion?

Please let me know, by opening a new issue or a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optimize-images-1.2.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

optimize_images-1.2.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file optimize-images-1.2.0.tar.gz.

File metadata

  • Download URL: optimize-images-1.2.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.9.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for optimize-images-1.2.0.tar.gz
Algorithm Hash digest
SHA256 58628f10e0ceba6435ae155a56736906161688f50d637e1bf16e31aa81ba469b
MD5 ac8a1d242b51e2379b5e1e741f285fad
BLAKE2b-256 85de24332502a3657f9fb140e598042395fa348b6085e8a52cf629649fd272f0

See more details on using hashes here.

File details

Details for the file optimize_images-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: optimize_images-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.9.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for optimize_images-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95ba62e3df8dc1ccced5e8c7643fc494a15498194d3ec39e094b17a8f5558a6a
MD5 3a3037dc032379b2de6d871cc66bafca
BLAKE2b-256 e4cb84b2ff17fa1a4e59bdfea2bd3e74c3b7d558397e11001af5a04ab24c4c46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page