Skip to content
This repository was archived by the owner on Jul 2, 2018. It is now read-only.

kornelski/jpeg-compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Research JPEG encoder

Codename "Nether Poppleton"


The goal of this encoder is to produce files with best filesize/quality ratio, regardless of encoding speed or memory cost.

Experimental features:

  • Luma-weighed chroma subsampling — thin red lines on white or black background don't become desaturated.
  • Less aggressive DC quantization — less banding (but more blurriness) at very low qualities.
  • Derining by overflowing — less noise around black text on white background.

Usage

Compile with

make

Run

./encoder source.png output.jpg 50

Examples

These are carefully chosen examples that show certain improvements. They're not indicative of overall performance (and ImageMagick's JPEG encoder is generally okay).

Deringing

JPEG shouldn't be used for line art, but people still do it. Now they can fail less at it.

ImageMagick = 7721B (left), this encoder = 7349B (right)

ImageMagick This encoder

Deringing is implemented by overflowing white color (intensity used is 272 instead of 255). This way distortions are introduced out of visible range.

Subsampling

Color can be saved at half resolution. Poor subsampling darkens and desaturates red lines.

Original (left), ImageMagick = 7277B (middle), this encoder = 7173B (right)

OriginalImageMagick This encoder

This is done by weighing chroma by luma level. Needs further improvements to correct overall luminance.

Low DC quantization

Standard JPEG encoders are not tuned for very low quality. Bad quality doesn't have to be that bad.

ImageMagick = 5033B (left), this encoder = 4890B (right)

ImageMagick This encoder

This is done by tweaking quantization tables. Further improvements are possible.