Back to blog
Web DevMarch 30, 20255 min read

Embedding Copyright Metadata in Open Graph Images

Your OG images get shared, scraped, and reused without attribution all the time. Here is how to embed ownership metadata that survives most of that.

When you create a custom Open Graph image for your site, it becomes one of the more widely distributed assets you produce. Every time someone shares a link on Twitter, Facebook, or LINE, your OG image shows up. It gets saved, reposted, used in screenshots. If you ever need to prove ownership or just want basic attribution embedded in the file, you can add EXIF and IPTC metadata directly to the image.

Most image editing tools expose some of this but the easiest programmatic way is with exiftool on the command line, or piexif in Python.

Using Python and piexif

python
from PIL import Image
import piexif
import piexif.helper

def embed_copyright(input_path: str, output_path: str, metadata: dict):
    img = Image.open(input_path)
    
    exif_dict = {
        "0th": {
            piexif.ImageIFD.Artist: metadata.get("author", "").encode(),
            piexif.ImageIFD.Copyright: metadata.get("copyright", "").encode(),
            piexif.ImageIFD.ImageDescription: metadata.get("description", "").encode(),
            piexif.ImageIFD.Software: b"Execross Image Pipeline",
        },
        "Exif": {
            piexif.ExifIFD.UserComment: piexif.helper.UserComment.dump(
                metadata.get("comment", ""), encoding="unicode"
            ),
        },
    }
    
    exif_bytes = piexif.dump(exif_dict)
    img.save(output_path, exif=exif_bytes, quality=90, optimize=True)

embed_copyright(
    "og-image-raw.png",
    "og-image.png",
    {
        "author": "Execross",
        "copyright": f"Copyright 2025 Execross. All rights reserved.",
        "description": "Execross main Open Graph image",
        "comment": "Source: execross.com | Contact: [email protected]",
    },
)

What metadata survives where

EXIF data survives most file saves and transfers. It gets stripped by some platforms (Facebook strips EXIF from uploaded images, Twitter does too in some cases). But it survives being downloaded and re-saved in most desktop apps.

For web sharing purposes this mostly helps when someone downloads your image and uses it elsewhere. You can verify the metadata is present:

bash
exiftool og-image.png | grep -E "Author|Copyright|Description"

XMP as a supplement

XMP is a more modern metadata standard embedded as XML inside the image file. It survives more processing pipelines than EXIF. Adding XMP requires either exiftool or a library like python-xmp-toolkit:

bash
exiftool \
  -XMP:Creator="Execross" \
  -XMP:Rights="Copyright 2025 Execross" \
  -XMP:Description="Execross Open Graph Image" \
  -XMP:WebStatement="https://execross.com/legal/terms" \
  og-image.png

This is less about preventing misuse (anyone can strip metadata) and more about establishing a clear record of origin. If your image ever shows up somewhere it should not, having the metadata be part of the original file is a useful data point.

We run this as part of our asset generation pipeline so every OG image we create gets the same treatment automatically.

More articles