Output Image Settings - Format and Encoding

Output Image Settings / Format and Encoding

On this page:

By default, the SupaRes API uses auto mode for output image format. That means, the API will match the output format with its input conterpart. For example, if you supply an input image in JPEG format, you will also receive enhancements results as a JPEG file. You may, however, instruct the API to save enhanced images in arbitrary formats. SupaRes supports JPEG, PNG, and WebP.

JPEG

JPEG stands for Joint Photographic Experts Group and is the most popular raster image format on the Internet; it's used mainly for large photograpic content. It's a lossy format which does not support transparency nor animation.

To enforce JPEG output, use jpg as a format value within the output hash.

To ensure the smallest possible file size and increase the perceived loading speed, the SupaRes API always uses progressive encoding for JPEG images. You can change this behavior and specify baseline value for the encoding attribute, however we recommend against doing that.

If you know what you're doing, you can specify quality which takes an integer in the range 1 - 100. Please note that usable range is usually around 70 - 90 mark. The value you specify with quality parameter will be passed directly to our JPEG encoders.

{
    "output": {
        "format": "jpg",
        "quality": 75,
        "encoding": "baseline"
    }
}

PNG

PNG stands for Portable Network Graphics and is the second most popular raster image format on the Internet. It's a lossless format which supports transparency but does not support animation. Unlike GIF format, which only supports 8-bit color, PNG supports up to 24-bit color RGB with 8-bit transparency. This makes it an excellent format for images with alpha transparency and thousands of colors used. We highly recommend re-encoding your static GIF images into PNG format as the latter will always result in a smaller file size due to a more advanced compression algorithm.

To enforce PNG output, use png as a format value within the output hash.

{
    "output": {
        "format": "png"
    }
}

WebP

WebP is a format developed by Google and released in 2010. It employs both lossy as well as lossless compression techniques and supports both transparency and animation. According to Google, WebP lossless images are 26% smaller in size compared to PNGs and 25-34% smaller in size compared to JPEG images.

By default, the SupaRes API will produce lossy-compressed WebP images. If you'd like to use lossless compression, simply set "compression": "lossless" within the output hash however, we recommend to use the default lossy compression as it will yield images with the perfect balance of file size and quality.

If you know what you're doing, you can also specify quality which takes an integer in the range 1 - 100. Please note that usable range is usually around 70 - 90 mark. The value you specify with quality parameter will be passed directly to WebP encoders.

To enforce WebP output, use webp as a format value within the output hash.

{
    "output": {
        "format": "webp",
        "compression": "lossless",
        "quality": 90
    }
}