Image Transcoding Configuration

Image Transcoding is the process of converting JPG or PNG images in order to make file sizes smaller, thereby reducing the time it takes to send them across the Internet, or to take advantage of certain capabilities that some formats provide that others don't – for example, a byte reduction with newer image formats.

Note

At Instart we use the word "transcoding" for converting from one file format to another, as well as for changing quality/color/transparency/etc. without changing the format.

The prefix "trans" leads one to assume an image is converted from a source format (for example, JPG) to a different destination format (for example, WepP). "Re-encoding" is perhaps a more precise term for the process of converting a source format to another file of the same format – as we do when we take a source JPG image, reduce the quality level and the total number of bytes, and save it back to JPG format.

Instart has a set of optimizations that allow for a number of different transcoding approaches that take advantage of modern compression approaches, device-specific image formats, and the use of a set of methods to intelligently reduce the compression ratio of images – SmartVision – to ensure that images are processed to provide the best performance and quality possible. The system takes a number of factors into consideration when transcoding images, such as the source format, the actual visual content of the images, the quality levels, and even the requesting device’s capabilities. 

Transcoding JPG and PNG images in place – that is, JPG to JPG and PNG to PNG – allows a reduction in image data size in a number of ways, depending on the type. Data is removed in place and the resulting file retains the same name, but the overall data transfer per image is smaller. Image optimizations can be lossy (for JPGs) or lossless (JPGs and PNGs). This type of transcoding is generally always used, as it will make images smaller, even if only slightly.

Additionally, we support transcoding to more modern image formats such as WebP and JPEG XR. In this case the image retains the same name but its source format changes. This offers even better data size reduction, but such images can at this time only be displayed by Google Chrome in the case of WebP, or Microsoft Edge or Internet Explorer 10 and above in the case of JPEG XR.

Note

The maximum image size that the SmartVision algorithm will be applied to is 4000 x 4000, or 16,000,000 pixels. Images larger than this will be transcoded to a fixed quality level of 90% by default (this value is configurable via specifying a max value for the guard_pct parameter, as described in the section "JPG to JPG Transcoding with SmartVision" below.

SmartVision JPG Transcoding

For JPGs, we apply image analysis to individual images to determine the appropriate amount of quality reduction they can tolerate without any significant degradation to their perceived quality, on an image-by-image basis. In the past, we chose a single quality value that would be applied across an entire property. We inspected images for their existing quality level and only adjusted the quality for images above the chosen static quality level.

It turns out that perceptually, some images can tolerate being transcoded to lower quality levels without impacting the quality of experience for the image, while applying this same level to other images would have a visible impact to the quality of experience. We would conservatively choose a higher quality level across the property to assure it was good enough for the majority of the images.

If you were to try different amounts of quality reduction to a group of different images and look at the results, you would discern that some would be perfectly usable at, say, 50%, while others would tolerate maybe 90%. If you could separate the images into two separate groups and apply the different values to each group, you could reduce the total byte size of delivered images by more than if you just conservatively transcoded them all to 90%.

Our SmartVision technology allows us to intelligently pick an appropriate quality level for lossy transcoding for each individual JPG image on the property. This mechanism allows us to send each image with as few bytes as possible while maintaining a uniform quality of experience.

The SmartVision technology generates a set of signatures for each image. This set of signatures is then used to group images in clusters of like images based on a large set of different images. For example, a cluster may be a set of images of zoomed-out city views, or a set of images with products at medium shot, or a set of images with people in them. We have found that these related images will have the same optimal quality values as the others in the cluster when using JPG lossy transcoding. These clusters each have a separate quality level assigned to them. Thereafter, any image, when analyzed, can be assigned to a cluster and will have the quality level of the cluster it belongs with applied to it.

The quality level can be shifted up or down a little by having a set of profiles (safe, standard, and aggressive). These profiles allow for changing the bias between improving the quality of experience at the expense of performance, or improving performance at the expense of quality of experience.

JPGs can still be transcoded without SmartVision by setting a single quality level value which will be applied to all JPGs.

JPGs can also be transcoded to two modern image formats, WebP (on which SmartVision can also be used) and JPEG XR. These formats are inherently smaller than JPG files; however, currently only Google Chrome and Opera support WebP, and only Microsoft IE supports JPEG XR. The service detects the requesting browser and sends the appropriate image.

SmartVision PNG Transcoding

PNG is a normally lossless format, but we are able to apply SmartVision by reducing the amount of color information and discarding data that is not used. The reduction varies from image to image, but the result is an image that is significantly smaller in file size with no discernible visual difference.

PNGs can still be transcoded without SmartVision but the amount of reduction is minimal.

PNGs can also be transcoded to two modern image formats, WebP (on which SmartVision can also be used) and JPEG XR. These formats are inherently smaller than JPG files; however, currently only Google Chrome and Opera support WebP, and only Microsoft IE supports JPEG XR. The service detects the requesting browser and sends the appropriate image.

Basic configuration

General

There is a separate configuration block for each type of image transcoding, JPG or PNG. Configuration for each is wrapped within a smart_vision block:

smart_vision" : {
  "jpg_transcode" : {
    ...
  },
  "png_transcode" : {
    ...
  },
  ...
}

The smart_vision block can contain an op block in which the transcode operations (enabled by default) can be disabled. The op blocks can also contain constraints for applying the operation – for example, min/max file sizes for which this operation will be applied.

Possible settings in the op block are:

Field or blockDescription
enableA flag to enable or disable the operation. This is set to true in defaults.json.
size_bytesAn optional pair of integer values for the min/max file size for which this operation can be applied. If you only specify one of the pair, the default value (set in default.json) of the unspecified one applies.

For example:

"size_bytes" : {
   "min" : 1500,
   "max" : 640000
}

causes the feature to only be applied to files that are larger than 1500 bytes and smaller than 640000 bytes;

"size_bytes" : {
   "min" : 1500
}

causes the feature to only be applied to files that are larger than 1500 bytes and smaller than the default value of max

The default min value is 100

The default max value is 100000000

min_cache_hit_countOptional minimum number of cache hits for the resource before this operation will be applied. For example:
"min_cache_hit_count" : 1

means that the feature will not be applied until the resource has been served from the cache at least once.

The default is 0

priorityOptional priority of the operation in the queue for processing. 0 is lowest priority, and the maximum value of uint32, 4294967295, is highest priority.

The default is 0

min_ttlOptional minimum remaining TTL on the resource to qualify for this operation. The value must be suffixed by one of the following:
  • s: seconds
  • m: minutes
  • h: hours
  • d: days

The default is 0s

Important note on the deprecated basic_opt flag

The basic_opt flag is being deprecated in the near future and should not be used. If you are working on a config you should remove it – especially if it is set to false, in which cases unpredictable behavior might occur. All functionality that basic_opt was previously documented as having can be achieved by controlling the enable flag in the op block (turning off transcoding entirely) and the flag advanced_force_disable_smart (turning off smart transcoding and using a fixed quality percentage for all images).

JPG Transcoding

To configure JPG to JPG Transcoding with SmartVision

Smart transcoding of JPGs to JPG is the default behavior. No explicit jpg_transcode block is required, as it’s been enabled by default for all customers via customers2/global/proxy/defaults.json since around mid-August 2016.

To configure "legacy" JPG to JPG Transcoding

Prior to SmartVision, we did transcoding by setting a static quality percent in the property config. This is not recommended, but in case you want to disable the use of the JPG smart transcoding algorithm and revert to the legacy method, use the advanced_force_disable_smart flag set to true and add the individual quality control parameters, as in the following example:

"smart_vision": {
  "jpg_transcode": {
    "advanced_force_disable_smart": true,
    "lossy_quality_percent": 80
  }
}

Note that determining the best value for lossy_quality_percent is an empirical exercise that would normally require testing many images to be sure that the value you set is appropriate for all images on the site.

If SmartVision is disabled, and you don't add this parameter, its value is 100 by default, so little or no JPG optimization takes place.

To configure JPG to WebP and JPEG-XR Transcoding with SmartVision

If you want JPGs converted to WebP when requested by Chrome and to JPEG-XR when requested by IE/Edge, you would configure this as follows:

"smart_vision": {
  "jpg_transcode": {
    "to_webp": true,
    "to_jpg_xr": true
  }
}

(JPG to WebP and JPEG-XR is not enabled by default; see below.) 

To configure "legacy" JPG to WebP and JPEG-XR Transcoding

As with legacy JPG-JPG transcoding, use the advanced_force_disable_smart flag set to true to bypass the use of the smart transcode algorithm, and add the individual quality control parameters, as in the following example:

"smart_vision": {
  "jpg_transcode": {
    "advanced_force_disable_smart": true,
    "to_webp": true,
    "to_jpg_xr": true,
    "lossy_quality_percent": 40,
    "to_webp_quality_percent": 40,
    "to_jpg_xr_quality_percent": 40
  }
}

As with JPG to JPG transcoding, determining the best value for lossy_quality_percent is an empirical exercise that would normally require testing many images to be sure that the value you set is appropriate for all images on the site.

SmartVision is disabled, and you don't add these parameters, their value is 100 by default. But since WebP and JPEG-XR images are almost always smaller than the original JPG, this still results in some significant byte reduction for images served to Chrome and IE/Edge.

(JPG to WebP and JPEG-XR is not enabled by default; see below

To disable JPG Transcoding

If for any reason you need to completely disable JPG transcoding, do so as follows:

"smart_vision": {
  "jpg_transcode": {
    "op": {
      "enable": false
    }
  }
}

Note that this will disable any transcoding of JPGs, either by applying SmartVision or by transcoding to WebP or JPEG-XR, or by setting static quality percent values. 

PNG transcoding

To configure PNG to PNG Transcoding with SmartVision

Smart transcoding of PNGs to PNG is the default behavior. No explicit png_transcode block with op set to enable is required, as it’s been enabled by default for all customers via customers2/global/proxy/defaults.json since around mid-August 2016.

To configure "legacy" PNG to PNG Transcoding

Prior to SmartVision, we did PNG transcoding by simply re-encoding them, removing some metadata to achieve a small byte reduction. This is not recommended, but in case you want to disable the use of PNG smart transcoding and revert to the legacy method, use the advanced_force_disable_smart flag set to true, as in the following example:

"smart_vision": {
  "png_transcode": {
    "advanced_force_disable_smart": true
  }
}

To configure PNG to WebP and JPEG-XR Transcoding with SmartVision

If you want PNGs converted to WebP when requested by Chrome and to JPEG-XR when requested by IE/Edge, you would configure this as follows:

"smart_vision": {
  "png_transcode": {
    "to_webp": true,
    "to_jpg_xr": true
  }
}

(PNG to WebP and JPEG-XR is not enabled by default; see below.) 

To disable PNG transcoding

If for any reason you need to completely disable PNG transcoding, do so as follows:

"smart_vision": {
  "png_transcode": {
    "op": {
      "enable": false
    }
  }
}

Note that this will disable any transcoding of PNGs, either by applying SmartVision or by transcoding to WebP or JPEG-XR.

Configuration fields

This section describes all the available "knobs" for adjusting the behavior of Image Transcoding.

JPG to JPG Transcoding with SmartVision

The following fields in the jpg_transcode block can used to alter the default settings:

Field or blockDescription
guard_pctA range defined by a minimum and maximum percent within which SmartVision will be applied. That is, the greatest amount of quality reduction applied to a given image will never be less than the minimum guard_pct, and likewise the smallest amount of quality reduction will always be at least the maximum guard_pct, regardless of what the SmartVision algorithm determines.

The defaults are 10 for min, 90 for max.

profileSets a quality profile for SmartVision. These make a tradeoff between the size of the images and the quality of experience.

The values of profile are:

  • safe:  this value to used when a customer wants to have minimal impact to image quality, but results in a smaller byte reduction.
  • standard: this is middle ground between safe and aggressive. This results in a small impact to quality with a better chance of byte reduction.
  • aggressive: this results in a maximal byte reduction but will potentially have a visible impact on image quality for some images.

Both safe and standard take higher precedence than aggressive.

The default is standard.

The following is an example jpg_transcode block using some of these fields. Transcoding with SmartVision is on by default. The block uses the safe profile, and sets the guard_pct minimum set to 60 and maximum to 90.

"smart_vision" : {
  "jpg_transcode" : {
    "guard_percent" : {
      "min" : 60,
      "max" : 90
    }
  },
  ...
}

"Legacy" JPG to JPG Transcoding

This is not recommended, but in case you need to disable the use of the JPG smart transcoding algorithm and revert to the legacy method  (transcoding all JPG images to a fixed quality level rather than letting the SmartVision algorithm determine the quality level for each image), use the advanced_force_disable_smart flag set to true and add the individual quality control parameters described below:

Field or blockDescription
lossy_quality_percentThe percent quality of transcoded JPG images relative to the original image, if SmartVision is not used. This means instead of using SmartVision to determine an appropriate quality percentage on an image-by-image basis, you are using a single fixed quality percentage for all images.

If the value is set to 100, image quality will be kept as it is, but there is still a small reduction in size.

If the initial image quality is greater than lossy_quality_percent, and the file size is larger than lossy_min_size_bytes, the transcoded image will have its quality reduced to this level.

The default is 100.

lossy_min_size_bytesThe minimum file size in bytes above which JPG files will be transcoded if SmartVision is disabled and the images are of higher quality than the lossy_quality_percent.

The default is 1500.

To illustrate the interaction of the lossy_quality_percent and lossy_min_size_bytes parameters, say that you have the following configuration:

"smart_vision" : {
  "jpg_transcode" : {
    "advanced_force_disable_smart" : true,
    "lossy_quality_percent" : 90,
    "lossy_min_size_bytes" : 64000
  },
  ...
}

and consider these three images:

  • img1.jpg is at a quality of 100% and is 2MB in size
  • img2.jpg is at a quality of 80% and is 3MB in size
  • img3.jpg is at a quality of 95% and is 500 KB in size

When the transcoding operation is applied to these images:

  • img1 will be transcoded to 90% quality
  • img2 will be left alone (although it is 3MB, its quality of 80% is below the 90% threshold)
  • img3 will left alone (although its quality of 90% is above the 90% threshold, its file size is smaller than the 64000-byte threshold.)

JPG Transcoding to WebP

Images can be transcoded from JPG to a more modern image format, WebP. WebP images can display the same image quality as JPGs and PNGs using significantly less data when the service detects that Google Chrome (which is currently the only browser capable of displaying the format) is the requesting user agent. This detection occurs automatically – you don't need to create an explicit predicate in the config to match the case of the browser being Google Chrome.

If SmartVision is enabled, it will be applied to this operation. This is a lossy transformation.

If SmartVision is not enabled, transcoding of JPG to WebP is lossless by default. The transformation can be configured to be lossy to further reduce data if desired with a minimal impact on quality. If enabled, the quality of JPG images to WebP will be performed in a more aggressive, lossy manner.

The following fields in the jpg_transcode block can be used to alter the default setting for conversion to WebP:

Field or blockDescription
to_webp

Boolean value to enable transcoding of JPG to WebP images to serve when request comes from a browser that supports this format.

The default is false.

to_webp_quality_percentNumeric value to set the quality percentage of JPG images as they are transcoded to WebP. Valid values are 1 to 100.

The default is 100.

webp_compression_levelThe amount of compression applied to WebP. Possible values are in the range from 0 to 6. 6 is the most compressed but the slowest to process; 0 is the least compressed but fastest to process.

The default is 4.

The following is an example jpg_transcode block where SmartVision is enabled by default, to_webp is set to true and to_webp_quality_percent is set to 70:

"smart_vision" : {
  "jpg_transcode" : {
    "to_webp" : true,
    "to_webp_quality_percent" : 70,
  },
  ...
}

The following is an example jpg_transcode block where SmartVision is disabled by use of the advanced_force_disable_smart flag, and to_webp is set to true and to_webp_quality_percent is set to 70. When the requesting browser is not Chrome, JPGs will not be reduced in quality (in the absence of an explicit setting for lossy_quality_percent, the default value of 100 is used). 

"smart_vision" : {
  "jpg_transcode" : {
    "advanced_force_disable_smart" : true,
    "to_webp" : true,
    "to_webp_quality_percent" : 70
  },
  ...
}

JPG Transcoding to JPEG-XR

Images can also be transcoded from JPG to another modern image format, JPEG XR. JPEG XR images can display the same or better image quality as JPGs and PNGs using significantly less data when the service detects that Microsoft Internet Explorer 10 or above (which is currently the only browser capable of displaying the format) is the requesting user agent. This detection occurs automatically – you don't need to create an explicit predicate in the config to match the case of the browser being IE.

The following fields in the jpg_transcode block can be used to alter the default setting for conversion to JPEG-XR:

Field or blockDescription
to_jpg_xrBoolean value to enable transcoding of JPG to JPEG XR images to serve when request comes from a browser that supports this format.

The default is false.

to_jpg_xr_quality_percentNumeric value to set the quality percentage of JPG images as they are transcoded to JPEG XR. Valid values are 1 to 100.

The default is 100.

The following is an example jpg_transcode block where SmartVision is enabled by default, and to_jpg_xr is set to true and to_jpg_xr_quality_percent is set to 80. When the requesting browser is not IE, JPGs will not be reduced in quality (in the absence of an explicit setting for lossy_quality_percent, the default value of 100 is used).

"smart_vision" : {
  "jpg_transcode" : {
    "profile" : "standard",
    "to_jpg_xr" : true,
    "to_jpg_xr_quality_percent" : 80
  },
  ...
}

The following is an example jpg_transcode block where SmartVision is disabled by use of the advanced_force_disable_smart flag, and to_jpg_xr is set to true and to_jpg_xr_quality_percent is set to 80. When the requesting browser is not IE, JPGs will not be reduced in quality (in the absence of an explicit setting for lossy_quality_percent, the default value of 100 is used).

"smart_vision" : {
  "jpg_transcode" : {
    "advanced_force_disable_smart" : true,
    "profile" : "safe",
    "to_jpg_xr" : true,
    "to_jpg_xr_quality_percent" : 80
  },
  ...
}

PNG to PNG Transcoding with SmartVision

Aside from disabling PNG Transcoding entirely by setting enable to false in an op block, there are no additional settings to configure. See the section "To disable PNG transcoding."

PNG transcoding to WebP

Images can be also be transcoded from PNG to WebP. WebP images can display the same image quality as JPGs and PNGs using significantly less data when the service detects that Google Chrome (which is currently the only browser capable of displaying the format) is the requesting user agent. This detection occurs automatically – you don't need to create an explicit predicate in the config to match the case of the browser being Google Chrome.

WebP supports an 8-bit alpha channel for transparency.

Image transcoding of PNG to WebP is lossless by default, but it can also be configured to be lossy to further reduce data if desired with a minimal impact on quality. If enabled, the quality of PNG images to WebP will be transposed in a more aggressive, lossy manner. The alpha and non-alpha channels of PNG images can be lossy – we can specify either, both, or neither.

The following fields in the png_transcode block can be used to alter the default setting for conversion of PNGs to WebP:

Field or blockDescription
to_webpBoolean value to enable transcoding of PNG to WebP images to serve when request comes from a browser that supports this format.

The default is false.

to_webp_quality_percentNumeric value to set the quality percentage of the non-alpha channels of PNG images as they are transcoded to WebP. Valid values are 1 to 100.

The default is 100.

to_webp_quality_alpha_percentNumeric value to set the quality percentage of the alpha channel of PNG images as they are transcoded to WebP. Valid values are 1 to 100.

The default is 100.

webp_compression_levelThe amount of compression applied to WebP. Possible values are in the range from 0 to 6. 6 is the most compressed but the slowest to process; 0 is the least compressed but fastest to process.

The default is 4.

The following is an example png_transcode block where SmartVision is enabled by default, and to_webp is set to true and to_webp_quality_percent is set to 70. When the requesting browser is not Chrome, PNGs will not be reduced in quality.

"smart_vision" : {
  "png_transcode" : {
    "to_webp" : true,
    "to_webp_quality_percent" : 70
  },
  ...
}

The following is an example png_transcode block where SmartVision is disabled by use of the advanced_force_disable_smart flag, and to_webp is set to true and to_webp_quality_percent is set to 70. When the requesting browser is not Chrome, PNGs will not be reduced in quality.

"smart_vision" : {
  "png_transcode" : {
    "advanced_force_disable_smart" : true,
    "to_webp" : true,
    "to_webp_quality_percent" : 70
  },
  ...
}

PNG transcoding to JPEG XR

Images can also be transcoded from PNG to JPEG XR. JPEG XR images can display the same or better image quality as JPGs and PNGs using significantly less data when the service detects that Microsoft Internet Explorer 10 or above (which is currently the only browser capable of displaying the format) is the requesting user agent. This detection occurs automatically – you don't need to create an explicit predicate in the config to match the case of the browser being IE.

JPEG-XR supports an 8-bit alpha channel for transparency.

Image transcoding of PNG to JPEG XR is lossless by default, but the alpha and non-alpha channels can also be configured to be lossy to further reduce data if desired with a minimal impact on quality. Specify the to_jpg_xr_transcoding_quality and/or to_jpg_xr_transcoding_quality_alpha parameters.

The following fields in the png_transcode block can be used to alter the default setting for conversion of PNGs to JPEG XR:

Field or blockDescription
to_jpg_xrBoolean value to enable transcoding of PNG to JPEG XR images to serve when request comes from a browser that supports this format.

The default is false.

to_jpg_xr_quality_percentNumeric value to set the quality percentage of the non-alpha channels of PNG images as they are transcoded to JPEG XR. Valid values are 1 to 100.

The default is 100.

to_jpg_xr_quality_alpha_percentNumeric value to set the quality percentage of the alpha channel of PNG images as they are transcoded to JPEG XR. Valid values are 1 to 100.

The default is 100.

The following is a sample png_transcode block where SmartVision is disabled by use of the advanced_force_disable_smart flag, to_jpg_xr is set to true, and to_jpg_xr_quality_percent is set to 80 and to_jpg_xr_quality_alpha_percent to 75. When the requesting browser is not IE, PNGs will not be reduced in quality.

"smart_vision" : {
  "png_transcode" : {
    "advanced_force_disable_smart" : true,
    "profile" : "aggressive",
    "to_jpg_xr" : true,
    "to_jpg_xr_quality_percent" : 80,
    "to_jpg_xr_quality_alpha_percent" : 75
  },
  ...
}

Other SmartVision configuration settings

The following additional settings can be made outside of the jpg_transcode and png_transcode blocks to tweak the SmartVision algorithm:

Field or blockDescription
webp_referer_checkEnable referer check for JPG and PNG to WebP transcoding

The default is false.

jpg_xr_referer_checkEnable referer check for JPG and PNG to JPEG XR transcoding

The default is false.

webp_with_webp_mime_typeSets MIME type to image/webp. Note that the file extension will still be PNG or JPG.

The default is true.

downsample_factorDownsample factor to be used by the SmartVision algorithm. We reduce height and width of the images by this factor to reduce CPU usage.

If, after downsampling the image, the resulting image size is below downsample_min_width and/or downsample_min_height, we double the downsampling factor and try again; and repeat until the resultant image is large enough or until the factor becomes 1.0.

The maximum value is 1.00

The default is 0.125

downsample_min_widthMinimum SmartVision image width in pixels. We won't downsample images to a width smaller than this.

The default is 100.

downsample_min_heightMinimum SmartVision image height in pixels. We won't downsample images to a height smaller than this.

The default is 100.

Image Transcoding configuration examples

Example 1

"smart_vision" : {
  "jpg_transcode" : {
    "profile" : "safe",
    "to_webp" : true,
    "to_jpg_xr" : true,
  },
  "png_transcode" : {
    "to_webp" : true,
    "to_jpg_xr" : true
  }
}

In this example

  • JPG transcoding is enabled
    • SmartVision is using the safe profile for JPGs
    • to_webp is set to true, so when the requesting browser is Chrome, the image will be transcoded to WebP; to_webp_quality_percent is not set explicitly, so the quality level is 100% by default
    • to_jpg_xr is set to true, so when the requesting browser is IE, the image will be transcoded to JPEG XR; to_jpg_xr_quality_percent is not set explicitly, so the quality level is 100% by default
  • PNG transcoding is enabled
    • to_webp is set to true, so when the requesting browser is Chrome, the image will be transcoded to WebP; to_webp_quality_percent is not set explicitly, so the quality level is 100% by default
    • to_jpg_xr is set to true, so when the requesting browser is IE, the image will be transcoded to JPEG XR; to_jpg_xr_quality_percent is not set explicitly, so the quality level is 100% by default

Example 2

"smart_vision" : {
  "jpg_transcode" : {
    "op" : {
      "size_bytes" : {
        "min" : 1500
      }
    },
    "guard_percent" : {
      "min" : 60,
      "max" : 90
    },
    "profile" : "aggressive",
    "to_webp" : true,
    "to_webp_quality_percent" : 80,
    "to_jpg_xr" : true,
    "to_jpg_xr_quality_percent" : 80,
  },
  "png_transcode" : {
    "op" : {
      "min_cache_hit_count" : 1
    },
    "to_webp" : true,
    "to_jpg_xr" : true,
    "to_jpg_xr_quality_percent" : 80
  },
  "webp_with_webp_mime_type" : true,
  "downsample_factor" : 0.125,
  "downsample_min_width" : 120,
  "downsample_min_height" : 120
}

In this example

  • JPG transcoding is enabled by default; the op block contains a size_bytes constraint with a min value of 1500 bytes. This means that images smaller than 1.5 KB will not be transcoded.
    • A guard_pct range is set with a min of 60 and a max of 90, which means that the greatest amount of quality reduction applied to a given image will never be less than 60%, and the amount of quality reduction will always be at least 90%, regardless of what the SmartVision algorithm happens to determine.
    • SmartVision is using the aggressive profile
    • to_webp is set to true and to_webp_quality_percent is set to 80, so when the requesting browser is Chrome, the image will be transcoded to WebP with a quality level of 80%
    • to_jpg_xr is set to true and to_jpg_xr_quality_percent is set to 80, so when the requesting browser is IE, the image will be transcoded to JPEG XR with a quality level of 80%
  • PNG transcoding is enabled by default; the  op block also contains a min_cache_hit_count of 1. This means that the image must have had a least one cache hit before it will be transcoded.
    • to_webp is set to true, so when the requesting browser is Chrome, the image will be transcoded to WebP; to_webp_quality_percent is not set so the quality level is 100% by default
    • to_jpg_xr is set to true and to_jpg_xr_quality_percent is set to 80, so when the requesting browser is IE, the image will be transcoded to JPEG XR with a quality level of 80%
  • SmartVision has the following overall constraints:
    • webp_with_webp_mime_type is set to true. This means the MIME type of images converted to WebP is set to to image/webp. Note that the file extension will still be PNG or JPG.
    • downsample_factor is set to 0.125, downsample_min_width is set to 120, and downsample_min_height is set to 120. This means that when SmartVision transcodes an image it first reduces its dimensions by 1/8th. If the resulting image is smaller in height than 125 pixels and/or smaller in width than 120 px, the downsample_factor is increased to 1/4th and the resulting image will again be checked against the min_width and min_height, and so on until either the image is outside those constraints of until the factor reaches 1.0, in which case the image will remain at its original size.

FAQ

How do we apply SmartVision to PNGs, since PNG is a lossless format?

The term SmartVision has been broadened to be an umbrella term to describe any of the methods we apply to intelligently reduce the compression ratio of images. The way we do it for PNGs is by reducing the amount of color information, discarding data that is not used. The reduction varies from image to image, but the result is an image that is significantly smaller in file size with no discernible visual difference.

Why is transcoding to WebP and JPEG-XR not enabled by default?

In the past we had a customer escalation for a scenario where transcoding to WebP was enabled. Because the image was a component of a Flash app, delivering a WebP image broke the app.

Since each customer use case is different, we do not want to enable transcoding to WebP and JPEG-XR by default. You will need to examine the customer's needs and find out if enabling WebP and JPEG-XR is appropriate for their site.