Output Image Settings - Format and Encoding

Output Image Settings / Format and Encoding

By default, the Optidash 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 processed images in arbitrary formats. Optidash supports GIF, JPEG, JPEG 2000, PNG, and WebP.

GIF

GIF stands for Graphics Interchange Format and is a palette-based lossless raster image format which supports very limited transparency (one color) and animation (up to 10 frames per second). GIF can store up to 8 bits of color per pixel allowing for up to 256 colors per frame.

To enforce GIF output, use gif as a format value within the output hash.

{
    "output": {
        "format": "gif"
    }
}

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.

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"
    }
}

JPEG 2000

JPEG 2000 is considered to be the next iteration of JPEG image compression and can yield smaller file size with a better visual quality of the resulting image. JPEG 2000 is currently only supported by Safari and iOS Safari browsers which translates to ~13% of global browser reach. It's a lossy format which does not support transparency nor animation.

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

{
    "output": {
        "format": "jp2"
    }
}

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 Optidash 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
    }
}