Use Case 7 min read

Keep AI-image labels when optimizing product photos for Google Shopping

A tested Sharp example shows how resizing can remove AI-image metadata. Preserve the source label, review private fields and check the file your product feed serves.

By ImageGuide Team · Published September 5, 2026
AI imagesGoogle ShoppingIPTCmetadataSharp

A resize can leave a product image looking unchanged while removing the field that identifies how it was made. In our test, an 800-pixel JPEG contained an XMP source label. After a default Sharp resize, the 400-pixel export had no XMP at all.

That matters for product feeds. Google Merchant Center requires AI-generated images to carry the IPTC DigitalSourceType property. It also tells merchants to preserve embedded source-type labels. Adding “AI-generated” to a filename or alt attribute does not put that property into the image file.

What the field contains

DigitalSourceType describes the image’s origin. The value for an image created with a trained generative model is the full identifier below, including its capitalization:

http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia

IPTC distinguishes generated images from photographs edited with generative tools. Its vocabulary includes compositeWithTrainedAlgorithmicMedia for generative editing. Preserve a valid existing classification and consult the IPTC vocabulary when classifying a new asset. Do not label every photograph as fully generated just because an editor has AI features.

This field records a claim about origin. It is not a cryptographic signature, proof of ownership or a guarantee that a shopping platform will approve the image.

The resize test

We used Sharp 0.35.3 on 5 September 2026. The input was a plain-color metadata fixture with an intentionally inserted source label. It was not a product photo or an export from an AI service. That keeps the experiment focused on metadata transport.

Stage Width File size XMP present?
Tagged JPEG fixture 800 px 3,520 bytes Yes
Default JPEG resize 400 px 981 bytes No
Resize with keepXmp() 400 px 1,382 bytes Yes

The preserved export still contained the source-type URI. The extra 401 bytes in this example carried the XMP packet. These sizes describe a solid-color fixture, so they say nothing about compression savings on photographs.

Download the input, stripped export, preserved export and complete result.

Preserve reviewed XMP during export

For a source whose XMP you have already reviewed, the relevant change is one method call:

import sharp from 'sharp';

await sharp('reviewed-source.jpg')
  .autoOrient()
  .resize({ width: 1200, withoutEnlargement: true })
  .keepXmp()
  .jpeg({ quality: 85 })
  .toFile('product-feed.jpg');

Sharp documents that default output drops metadata and provides separate XMP preservation and writing methods. keepXmp() keeps the packet. It does not identify which fields you intended to publish.

XMP can contain location, creator and contact information too. Review it before using this example on customer uploads. If you need selective retention, parse it with a maintained metadata library, select the approved fields and serialize a new packet. Do not filter arbitrary XML with a regular expression or copy untrusted values into an XML string.

If the original has no source label, keepXmp() cannot invent one. Return to the original export or assign a label from a trusted record of how the image was produced.

Check each file boundary

Keep the original export and inspect four versions of the asset:

  1. The editor’s download, before any cleanup tool touches it.
  2. The resized or compressed file you upload.
  3. The stored original on your image host.
  4. The response served by the exact URL in your product feed.

The last step catches transformations after upload. A correct local file does not establish what a crawler receives. Download the feed URL, follow redirects and inspect that file:

curl --fail --location --show-error \
  'https://your-image-host.example/products/shirt-feed.jpg' \
  --output delivered.jpg

With Sharp installed, save this as inspect-xmp.mjs and run node inspect-xmp.mjs delivered.jpg:

import sharp from 'sharp';

const file = process.argv[2];
if (!file) throw new Error('Pass an image filename');
const metadata = await sharp(file).metadata();
console.log(metadata.xmp?.toString() ?? 'No XMP packet found');

This prints the packet for inspection. It is not a semantic validator. Check that the expected property and value survive. If the host negotiates formats, inspect each response format your feed URL can serve rather than assuming the JPEG test covers WebP or AVIF too.

We tested the local Sharp operation, not the retention policy of an image CDN or the output of a specific AI editor. Apply the same check after editing a background in Sirv AI Studio or another editor. For automated editing workflows, include the check after downloading the result from the Sirv Studio API.

Reproduce the result

From an ImageGuide checkout with dependencies installed:

node public/experiments/2026-09/run.mjs metadata

The experiment source asserts that default resizing removes the fixture’s XMP and that the preservation branch retains the label. It writes the three files and a JSON report with library versions.

Add a check like this to the step that produces feed images. Keep the source label, remove private information deliberately and inspect the delivered file before submitting its URL.

Related Resources

Resize and deliver images with Sirv

Upload your images to Sirv, then request the sizes and formats your pages need.

Get started