Chapter 12. Compressing Image Data Types
If you’re an application developer, chances are that the bulk of your app content is actually image data. Social media streams, shopping pages, even mapping information are all image content that must be sent down to your users, constantly.
Image compression is a really tricky subject. The individual lossy algorithms inside the compressors are gnarly (at best) and really should not be touched. But don’t lose hope. Although these compressors are mostly treated as black-box systems, there’s still a lot that your development team can do to influence the size of image content, and make it smaller.
Understanding Quality Versus File Size
Typically, image compressors provide an integer parameter that lets you define a quality metric for the image.1
As this value gets lower, so does the file size—and the image quality.
You see, this value mostly controls how aggressive the lossy algorithms are in transforming the data for better compression. So, lower quality means that more colors are discarded or more edge information is ignored, all to generate more duplicate symbols for subsequent statistical encoding stages.
Choosing the value for this quality metric should be a huge, important, time-consuming decision. Picking a value that is too low results in bad image artifacts, and users might complain about a lack of quality. Picking a value that is too high means you’re sending around larger files than you need to, and paying the cost for that as well. ...
Get Understanding Compression now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.