Image quality analysis
Last updated: Sep-02-2024
You may want to determine the quality of images uploaded to your product environment, particularly for user generated content. If you set the quality_analysis
parameter to true
, a quality analysis focus score between 0.0 and 1.0 is returned indicating the quality of focus in the image. A score of 0.0 means the image is blurry and out of focus and 1.0 means the image is sharp and in focus.
You can request quality analysis while uploading an image, or by using the explicit method on an already uploaded image.
See also: Image quality analysis using the Cloudinary AI Content Analysis add-on.
Quality analysis while uploading
You can request quality analysis while uploading by specifying the quality_analysis
parameter in the upload method.
For example, uploading the "user_photo.jpg" image and requesting quality analysis:
Quality analysis on already uploaded images
There are two ways to request quality analysis on already uploaded images:
- Use the Explicit method of the Upload API to request quality analysis on a single asset. This method is not rate-limited and requires a signature to be generated on the server side.
- Use the Update resources method of the Admin API. This method is rate-limited and requires your API key and secret, so is not suitable for use in client-side code.
Explicit example
The following example uses the Explicit method of the Upload API to request quality analysis on the image with a public ID of "user1":
Update resources example
The following example uses the Update resources method of the Admin API to request quality analysis on an uploaded image with a public ID of "table":
Sample response
Extended quality analysis
A more detailed quality analysis of uploaded images is available through extended quality analysis.
With extended quality analysis activated, the response to an upload or explicit request with quality_analysis
set to true
includes scores for different quality factors in addition to the normally available focus related score. An overall weighted quality score is also included:
- Scores vary from 0.0 (worst) to 1.0 (best).
- For multi-page images, only the first page is evaluated.
-
jpeg_*
scores are only present for JPEG originals. - JPEG quality is considered best (1.0) if chroma is present for all pixels (no chroma subsampling).
- Estimation of compression artifacts (DCT, blockiness and chroma subsampling) is not done for images above 10 MP
- Resolution gives preference to HD (1920 x 1080) and higher.
-
pixel_score
is a measure of how the image looks in terms of compression artifacts (blockiness, ringing etc.) and in terms of capture quality (focus and sensor noise). Downscaling can improve the perceived visual quality of an image with a poor pixel score. -
color_score
takes into account factors such as exposure, white balance, contrast and saturation. Downscaling makes no difference to the perceived color quality.
The quality_score
, quality_analysis.color_score
and quality_analysis.pixel_score
fields can be used in the search method when quality_analysis
is set to true
in the upload request or an upload preset. Note that these scores are not indexed for search when returned as part of an explicit request.