Facebook Introduces Open-Source Image Processing Library

Facebook unveiled Spectrum, an open-source image processing library to help improve the quality and reliability of images uploaded through its own apps. Spectrum, which Facebook first showed publicly and launched in beta in November, is now on GitHub, available to the developer community. As higher quality cameras on smartphones have become a key selling point, consumers are dealing with larger image files, which can be a stumbling block since they eat up more device memory and more network bandwidth.

VentureBeat reports that this problem is why “apps such as WhatsApp and Facebook compress images.” The trade-off of compression, however, is image quality. “What was a 3MB picture at 2980 x 2384 pixel resolution could be roughly a fifth that size when displayed in the app, which translates to reduced clarity.”

Spectrum — defined as a “client-side image transcoding library for both Android and iOS apps” — also reduces file size (which means faster uploads and less data consumption) but, via a “declarative” API, makes it easier to control image quality without the app developer needing to write additional code. “In short, rather than telling an app step by step how an image should be transcoded, Spectrum allows developers to stipulate what they want done — and Spectrum takes care of the orchestration.”

Spectrum “prefers a lossless approach when cropping and rotating JPEG images,” said Facebook, but when resizing, it “optimizes the interplay between decoder sampling and pixel-perfect resizing.” Spectrum also “integrates with native image compression libraries, including MozJpeg, a JPEG encoder launched by Mozilla’s research team … which can reduce a file size by 10-15 percent in preparation for upload.”

This integration lets Spectrum control advanced parameters including chroma subsampling, “which is a compression practice that attributes less resolution to an image’s color in favor of luminance data.” For images requiring more defined colors (especially those involving illustrations or sharp images), Spectrum “intervenes.”

According to Facebook, “the consistent API makes these features accessible to developers who are not image experts.” Facebook reported that it’s been in development on Spectrum for 18 months, “gradually incorporat[ing] its own apps.” During its beta, Facebook “gathered input” and incorporated fixes and “support for less common” chroma subsampling in JPEG files.

No Comments Yet

You can be the first to comment!

Sorry, comments for this entry are closed at this time.