Skip to content

Command-line application for lossy compression of JPEG images.

License

Notifications You must be signed in to change notification settings

NikMohorko/image_compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image compressor

Command-line application for lossy compression of JPEG images, ideal for improving load time of websites.

Each image's final quality is iteratively determined using the structural similarity (SSIM) algorithm, so that the visual difference between original and compressed picture is optimal. Detailed results are saved to log.txt.

The SSIM algorithm is implemented in Cython to increase performance.

Supported input image types are: JPEG

Setup

  1. Use pip to install requirements:
pip install -r requirements.txt
  1. Navigate to app directory and compile the Cython module:
python setup.py build_ext --inplace
  1. Run:
python compressor.py [input dir] [output dir] [maximum dimension] [SSIM factor]

Arguments

  • input dir: Path to directory with original images
  • output dir: Path to directory where compressed images will be stored
  • maximum dimension: Optional; Maximum dimension in pixels to further reduce file size. If used, the aspect ratio will be preserved and width/height (whichever larger) will be set to this number.
  • SSIM factor: Optional; [0-1.0] SSIM factor, default value of 0.97 usually gives optimal results for most images

Testing

After compiling the Cython module you can run unit tests with:

pytest

Technologies used

  • Python 3.9
  • Cython

Resources

Wang, Zhou; Bovik, A.C.; Sheikh, H.R.; Simoncelli, E.P. (2004-04-01). "Image quality assessment: from error visibility to structural similarity". IEEE Transactions on Image Processing. 13 (4): 600–612.

Structural similarity

About

Command-line application for lossy compression of JPEG images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published