Image Encoder
A software module that compresses raw pixel data into a specific image format (JPEG, PNG, WebP, etc.) with configurable quality and compression settings.
An image encoder converts uncompressed pixel data (RGB/RGBA buffer) in memory into a specific file format. The encoding process applies compression algorithms, prepends format headers, and embeds metadata. Each format has dedicated encoders: libjpeg-turbo for JPEG, libpng/OxiPNG for PNG, and libwebp for WebP.
Encoder quality is measured by the balance between compression efficiency (file size at equivalent quality) and processing speed. MozJPEG, for example, can produce smaller files than standard libjpeg at the same quality but encodes more slowly. How much smaller depends on the image and the encoder settings, so encoding the same image with both and comparing is the reliable check.
For client-side processing, browsers provide built-in encoders via Canvas toBlob(), while WebAssembly-compiled encoders offer superior compression ratios for demanding applications.