Format / Quality
Sirv can serve your images in either JPEG, PNG, GIF or WebP format - regardless of the original image format. By default, it does this automatically with the "optimal" format.
The default image format is called "optimal" and we recommend keeping this setting.
There are no settings to change - simply upload your images to Sirv in their existing format and Sirv will serve them in the best possible format for each users' device. Often, the smallest file size image format is WebP, so that is the format usually served to Chrome and Opera browsers, though sometimes an optimized PNG or a compressed JPEG may be more suitable.
Whether your original images are in JPEG, PNG or GIF format, the "optimal" format will ensure that every visitor receives the fastest loading image format for their device. Read more about format=optimal on our blog.
To always serve the original image format to all devices/browsers, set the 'format' parameter to "original":
With the original format, images will be optimized and/or compressed but they will not change the format.
WebP is a modern image format that you'll instantly benefit from when you use Sirv. The default "optimal" format automatically serves lossy WebP images to supporting browsers and either JPEG or PNG to unsupporting browsers.
WebP compresses images to much smaller file sizes than their PNG, JPEG and GIF equivalents. File size is typically 40-70% smaller and image quality is typically sharper. Developed by Google, WebP supports transparency, alpha, and animation, making it a powerful alternative to JPEG, PNG, and GIF.
As of November 2018, 72% of web users could view WebP images. Chrome, Edge, Opera and Android browsers support WebP now, while Firefox will support it from v65 onwards.
As WebP is enabled by default in the "optimal" image format, you need not specify it. However, if you want to specifically tell Sirv to serve your JPEG and PNG images in WebP format, set the 'format' option to 'webp' like so:
If you're currently using a WebP supporting browser, you'll see a WebP image below, otherwise you'll see a PNG:
When served as a PNG with transparent background, that 250px height image is 87 KB. When served in WebP format, it is only 18 KB.
If you've uploaded an image that is already in WebP format, your images will be served as WebP and will automatically fall-back to JPEG for unsupporting browsers.
Below is an original WebP. If your browser does not support WebP, Sirv automatically serves it in JPEG format:
To learn more about WebP, read Google's official WebP documentation.
Use the 'webp.fallback' option to control what format an original WebP image should fall back to when WebP isn't supported.
Original WebP images will fall back to JPEG. You can make them fall back to PNG like so:
There are two primary types of JPEG images: baseline and progressive.
Baseline JPEGs start loading with the fully rendered top of the image and then continue to draw in the rest of the image as the data is received.
Progressive JPEGs load the full image much faster but with fewer pixels. The image momentarily looks pixelated and then sharpens as the rest of the data loads. Progressive JPEGs can make the experience faster for viewers and is the preferred JPEG type for many developers.
By default, Sirv serves baseline JPEG. You can change it to progressive by setting the 'progressive' option to 'true'.
Chroma subsampling reduces the file size of JPEG images by 25% on average, without any noticeable impact on the image. Smaller file size helps images load faster and reduces data transfer, so Sirv applies subsampling of 4:2:0 by default.
Subsampling is expressed as a three part ratio J:a:b (e.g. 4:2:0) which describes the number of luminance and chrominance samples in a region that is J pixels wide, and 2 pixels high. The parts are (in their respective order):
- J: horizontal sampling reference (width of the conceptual region). Usually 4.
- a: number of chrominance samples (Cr, Cb) in the first row of J pixels.
- b: number of changes of chrominance samples (Cr, Cb) between first and second row of J pixels.
Sometimes, a very subtle color difference can be identified when comparing the original JPEG and the subsampled JPEG. If you have images which display visual differences due to chroma subsampling, you can change the 'subsampling' option. The available settings are 4:4:4, 4:2:2 and 4:2:0, where 4:4:4 has no subsampling and 4:2:2 has some subsampling:
The following 3 JPEG images have settings of 4:4:4, 4:2:2 and 4:2:0 respectively: