Open source Spectrum library enables edge processing of images for faster performance

Spectrum can be used to perform image processing on smartphones before uploading data to servers, providing higher quality images than native APIs.

How to understand serverless architecture in the cloud Chris Wegmann, who leads Accenture's AWS practice, spoke with TechRepublic at AWS re:Invent about the advent of serverless and what business leaders need to know.

Processing images taken from mobile phone cameras is a deceptively expensive task for both service operators and end users. Smartphone cameras have improved dramatically year after year, with even the $150 Redmi Note 7 capable of taking massive 48 megapixel pictures. Uploading these increasingly large files to social media services can quickly consume the data use allotment on an average smartphone plan. By processing huge quantities of images, website operators spend at scale substantial amounts of money on bandwidth and processing time in serverless computing platforms such as AWS Lambda in compressing images.

Smartphones clearly have the processing capabilities required to resize photos, though obtaining high quality image conversations, across platforms--and differing versions of the same platform, for Android--make handling this operation inconsistent between platforms, requiring code duplication and specialized handling for cases such as interpreting and preserving EXIF metadata on conversion. Similarly, native image processing APIs available on smartphone platforms use differing compression libraries, leading to inconsistent quality.

SEE: How to launch a successful developer career (Tech Pro Research)

Spectrum, an open source image processing library from Facebook, aims to give developers the ability to perform image transformation client-side, with predictable, repeatable results on different platforms. The library can be integrated into Android or iOS apps, and uses C/C++ code for higher performance with Java and Objective-C wrapper APIs for integration ease. Spectrum's API is declarative, allowing developers to define the target output characteristics, leaving the work of formulating settings to achieve that goal to the library itself.

Spectrum utilizes the latest version of MozJPEG, which is tuned for high performance in aspects of the JPEG standard, where other implementations fall flat or require extensive custom tuning to achieve. Most notably, MozJPEG extensively tunes JPEG quantization tables, prioritizing more accurate color reproduction over preservation of tiny details. This reduces color banding, making photos look better on high-DPI displays. Use of MozJPEG also allows for more complex encoding--which requires more processing time--but provides smaller files.

According to Facebook, use of Spectrum "allows a reduction of up to 15% in upload file size compared to a baseline encoder."

Developers can get started with documentation the library here, with the library itself available on GitHub.

The big takeaways for tech leaders:

  • Spectrum can be used as part of smartphone apps, reducing data usage and server-side processing time to resize photos.
  • Use of Spectrum "allows a reduction of up to 15% in upload file size compared to a baseline encoder." --Facebook, 2019

Also see

datacentervirtualizationistock-842457006vladimirtimofeev.jpg
caribb, Getty Images/iStockphoto