Facebook launches open-sourced Spectrum for better mobile image production
Facebook has officially released an open source tool to the developer community to make the process of uploading images more efficient.
Dubbed as โSpectrumโ, this tool is a cross-platform image transcoding library that can easily be integrated into an Android or iOS project to efficiently perform common image operations. It aims to improve the reliability and quality of image uploads while reducing image uploading time and mobile data consumption.
โAs modern smartphones capture high-resolution images, the large file size makes uploads unreliable on some mobile networks. Sending it at full resolution is often wasteful, as the content delivery network (CDN) will resize the image for the recipient anyway,โ said Facebook mobile software engineerย Daniel Hugenroth.
โResizing the image on the senderโs device reduces the bandwidth required to send the image. As a result, the entire pipeline has minimal payload overhead, improving the end-to-end experience. The remaining challenge is how to maintain image quality while benefiting from the smaller file.โ
Spectrum uses a โdeclarativeโ API that allows developers to focus on the desired output properties instead of the individual steps. It prefers a lossless operation for cropping and rotating JPEG images, while in resizing it โoptimizes the interplay between decoder sampling and pixel-perfect resizing.โย It also uses C/C++ code for higher performance with Java and Objective-C wrapper APIs to make development easier.
Spectrum integrates with native image compression libraries, including MozJpeg,ย that allows to control encoding parameters beyond the general-purpose platform APIs. It allows developers to utilize computationally intensive encoding, which requires more processing time but significantly reduces the file size. Additionally, it enables control over more advanced parameters such asย chroma subsamplingย to improve the quality of images with sharp edges and illustrations.
โThe consistent API makes these features accessible to developers who are not image experts,โ Hugenroth added.
โWe hope Spectrum will benefit developers in the same way it has helped Facebook create a better image production experience. In our apps, Spectrum has improved the reliability and quality of image uploads at large scale across our apps. The default integration with Mozilla JPEG allows a reduction of up to 15 percent in upload file size compared with a baseline encoder. We are excited to see how the community uses theย Spectrum 1.0.0 library to improve the photo experiences in applications.โ
The open source project โSpectrum 1.0.0โ is now available onย GitHub code repository.