Wednesday, April 13, 2016

[ghunzstp] Reducing image size

Some notes for reducing the data size of an image, inspired by people sending giant email attachments.

Crop.  Tools: gimp, pnmcut, jpegtran, exiftran

Reduce the resolution to what is necessary for what is being communicated.  Do you need to communicate roughly what a person looks like, or the exact layout of pores and hair follicles on their skin?  Tools: pnmscale

For JPEG (jpg), similarly reduce the compression quality to capture only the necessary detail.  Tools: cjpeg -q

Is color necessary or is grayscale good enough?  Tools: jpegtran -grayscale, ppmtopgm

For PNG: pngcrush -brute optimizes the image with no loss.

pnmdepth reduces the color depth.

Choose the best image format.  JPEG is good for real world photographs.  PNG is good for computer generated artwork, e.g., text and figures.  Djvu offers good compression of black-and-white text.

JPEG 2000 (jp2) offers even better compression than JPEG, especially at low bitrates, including the intriguing Region Of Interest (ROI) feature for higher quality for only part of an image.  Tools: JJ2000 jasper.

Other image formats: BPG, WebP, JPEG XR

Computer generated figures that started out as vector graphics format (Adobe Illustrator, Visio, Dia) will probably take up less space exported as compressed svg than to a raster image format like PNG.  Other vector formats: Postscript (ps), PDF.  Plus, vector provides infinite resolution!  Tools for lossless data compression: gzip bzip2 xz.

A picture of text takes up much more space than, say, HTML with CSS.

A vector image exported to an antialiased raster compresses worse with PNG than without antialiasing, though omitting antialiasing might be ugly.

No comments :