← Back to team overview

ubuntu-manual team mailing list archive

Size optimization – image compression

 

Salve,

this is the size report for the current PDF output:

info: This is pdfsizeopt.py rUNKNOWN.
info: computing statistics for PDF: /ubuntu-manual-beta.pdf
info: PDF size is 4854757 bytes
info: stat contents_objs = 354956 bytes (7%)
info: stat font_data_objs = 80251 bytes (2%)
info: stat header = 15 bytes (0%)
info: stat image_objs = 4106007 bytes (85%)
info: stat linearized_xref = 0 bytes (0%)
info: stat other_objs = 260003 bytes (5%)
info: stat separator_data = 24 bytes (0%)
info: stat trailer = 49 bytes (0%)
info: stat wasted_between_objs = 0 bytes (0%)
info: stat xref = 53452 bytes (1%)

It shows, the low hanging fruit is in the images (85%). The codec
options for images are JPG and PNG. I would go JPG on a case-by-case
basis (everything with photos or large desktop background in it) and PNG
by default.

24-bit PNG is a waste for screenshots in general. If the shot »needs«
24-bit, then it should be JPG. Otherwise I recommend to automatically
quantize with a good quantizer and dither (i.e. not Floyd-Steinberg or
random).

This works well:
https://code.launchpad.net/~exoticorn/+junk/exoquant

$ exoquant -v -n 48 screenshots/en/*.png

For discussion and other (less automated) methods see: 
http://xiphmont.livejournal.com/35634.html


This saves 60% file size at negligible visual deterioration.

Then, switching XeTeX (via setting in dvipdfmx.cfg2) to use PDF version
1.6 saves another 260k.

Result: 1.8 MB vs. 4.9 MB

info: This is pdfsizeopt.py rUNKNOWN.
info: computing statistics for PDF: /ubuntu-manual/main.pdf
info: PDF size is 1715143 bytes
info: stat contents_objs = 355569 bytes (21%)
info: stat font_data_objs = 96548 bytes (6%)
info: stat header = 15 bytes (0%)
info: stat image_objs = 950772 bytes (55%)
info: stat linearized_xref = 0 bytes (0%)
info: stat other_objs = 259314 bytes (15%)
info: stat separator_data = 24 bytes (0%)
info: stat trailer = 49 bytes (0%)
info: stat wasted_between_objs = 0 bytes (0%)
info: stat xref = 52852 bytes (3%)
info: end of stats


The exoquant run could be put into the Makefile, but there may be images
that need more colors than 48, so I dunno. Exoquant preserves alpha
channel so semi-transparent figures are possible.

--Tobias

Attachment: quantized-example.png
Description: PNG image