Documentation menu

Guides

Strip metadata

Remove camera, location, author and software details from an image or a PDF without changing what it shows.

The request

POST/v1/strip-metadata

Send the file as the request body. The response body is the same file, in the same format, without its metadata. The operation has no options.

curl -X POST "https://api.smolmac.com/v1/strip-metadata" \
  -H "Authorization: Bearer $SMOL_API_KEY" \
  --data-binary @IMG_2041.jpg \
  -o IMG_2041.clean.jpg

It works on images and PDFs. Any other kind of file is refused with 415 unsupported_input. To remove the tags of an audio file, compress it with audio.strip_metadata=true; see Audio.

In a job the operation is written with an underscore: "operation": "strip_metadata". The path of the direct endpoint uses a hyphen.

What is removed

For images, every metadata block in the file is removed, apart from the two items in the next section:

RemovedExamples
LocationGPS latitude, longitude and altitude
Camera and lensMake, model, serial numbers, lens, exposure settings
TimeWhen the picture was taken and when it was edited
SoftwareThe apps that created or edited the file
Descriptive dataXMP and IPTC: author, copyright, captions, keywords, edit history
Embedded thumbnailsA small preview, which can show the picture as it was before a crop

BMP files have nowhere to store metadata. A BMP is returned unchanged, with a warning in the result object that says so.

What is kept, and why

Two items are left in an image on purpose:

KeptWhat it doesWhat happens without it
Orientation tagTells a viewer to rotate the picture. Cameras and phones often store a portrait photo sideways and set this tag.The picture displays on its side.
Colour profile (ICC)Tells a viewer what the colour numbers in the file mean, for example Display P3.Colours shift, most visibly on wide-gamut photos.

Neither says anything about a person, a place or a device. They are instructions for displaying the pixels. Removing them would change what the image looks like, which this operation must not do.

PDFs

For a PDF, the document information (title, author, subject, keywords, creating application, dates) and the XMP metadata are removed.

The pages, text, images and fonts of the PDF are not changed. A PDF that needs a password to open is refused with 422 encrypted_pdf.

This removes metadata about the document. It does not look inside the pages: a name typed in the text, or a photo embedded in a page that has its own EXIF data, is content and stays.

It is lossless

The image data is not decoded and not re-encoded. Every pixel of the output is the pixel of the input, at the same dimensions, in the same format. Only the metadata blocks are taken out of the file, so the output is slightly smaller.

Smol-Result header, formatted
{
  "kind": "image",
  "input_format": "jpg",
  "output_format": "jpg",
  "original_size": 3482915,
  "output_size": 3441102,
  "savings_percent": 1.2,
  "kept_original": false,
  "increased": false,
  "width": 4032,
  "height": 3024,
  "pages": null,
  "duration_seconds": null,
  "video_codec": null,
  "warnings": []
}

For a PDF, the page content is likewise untouched. The file structure is rewritten, so the size can change a little in either direction.

Strip or compress

POST /v1/compress also removes metadata from images by default. Use the operation that matches what you want to keep:

You wantUse
The exact same pixels, minus the metadataPOST /v1/strip-metadata
A smaller file, and no metadataPOST /v1/compress with its defaults. See Compress images.

Limits and billing

  • A direct request takes a file of up to 25 MB. Larger files go through a job. See Large files and jobs.
  • The pixel limit for images and the page limit for PDFs apply as they do for compression. See Limits.
  • Each file counts as one image: $0.010 for the first 10,000 images in a calendar month, then $0.0022. This is the same for a PDF, whatever its page count.
  • Failed requests are free.

How files are handled while they are with us is described in How files are handled.