This repository contains all analysis scripts and data that are covered by the blog post JPEG Quality estimation: experiments with a modified ImageMagick heuristic.
Below scripts were tested with Python 3.8.10. They use the Pillow Imaging Library, which can be installed using:
pip install pillow
- test-jpegquality-im-original.py: computes JPEG quality for one or more files using original ImageMagick heuristic. Option
--verbose
prints out values of all variables in main loop at each iteration. - test-jpegquality-im-modified.py: computes JPEG quality for one or more files using modified ImageMagick heuristic. Option
--verbose
prints out values of all variables in main loop at each iteration. - test-jpegquality-tablematch.py: computes JPEG quality for one or more files using direct comparison against standard JPEG quantization tables.
- test-jpegquality-compare.py: computes JPEG quality for one or more files using all of the above methods and write results in comma-delimited format.
- generate-testimages-pillow.py: generates a set of JPEG images at 6 quality levels from a user-defined source image.
- generate-testimages-im.sh: generates a set of JPEG images at 6 quality levels from a user-defined source image using ImageMagick.
- test-quantization.py: reads the quantization tables of one or more files and writes the values to 2 comma separated text files.
Both quality estimation scripts are derived and modified from the Python port of ImageMagick's heuristic by Eddy O (AKA "eddygeek"). In turn this port is based on ImageMagick's original code.
The directory images contains the following folders:
- im_pil: test images created with Python's Pillow library and and ImageMagick. Each image is compressed at level indicated in filename.
- source: source images for all Pillow and ImageMagick test images.
- dbnl: examples of problematic access and master JPEGs from DBNL scans.
- misc: miscellaneous images, most of these give different quality estimates depending on which tool/method is used.
- image-98.jpg, image-177.jpg: taken from sample-images
- sample-birch-400x300.jpg: taken from samplelib.com
- sample-jpg-files-sample-4.jpg: taken from toolsfairy.com
- jpeg420exif.jpg, jpeg422jfif.jpg and jpeg444.jpg taken from w3.org
- hopper_16bit_qtables.jpg: taken from Pillow test images.