APIs and SDKs

Image metadata

This article takes a closer look at the types of metadata available for images and the values they might return.

The metadata option for image fields controls which types of metadata Sanity extracts or generates from uploaded images and saves alongside the asset.

Image assets in your Content Lake may include a range of helpful metadata.

  • Always included: Essential facts about your image, including height, width, aspect ratio, and information about transparency.
  • Included by default: Useful information generated from the image on upload: minified placeholders and palette values.
  • Excluded by default: Potentially private information about the place and circumstances under which the image was created, held in the exif, image, and location values.

An example of an image field with every metadata option specified looks as follows:

{
  name: 'metaImage',
  title: 'Image with metadata',
  type: 'image',
  options: {
    metadata: [
      'blurhash',   // Default: included
      'thumbhash',  // Default: included
      'lqip',       // Default: included
      'palette',    // Default: included
      'image',      // Default: not included
      'exif',       // Default: not included
      'location',   // Default: not included
    ],
  },
},

There are three additional metadata options that are always included and cannot be disabled: dimensions, hasAlpha, and isOpaque. Specifying an invalid option in the metadata array (including any of those three terms) will throw an error.

The metadata fields fall into one of three "default behaviors": always included, included by default, and excluded by default. We'll look at each default setting and the metadata fields that adhere to it.

Gotcha

Gotcha

Alpha channel, opaqueness, and dimensions