Skip to content

Instantly share code, notes, and snippets.

@stephanie-w
Last active April 12, 2021 11:38
Show Gist options
  • Select an option

  • Save stephanie-w/44df6adb1227f16c4788f05466894247 to your computer and use it in GitHub Desktop.

Select an option

Save stephanie-w/44df6adb1227f16c4788f05466894247 to your computer and use it in GitHub Desktop.
from PIL import Image
import piexif
message = "Hello World!"
im = Image.open("cover.jpg")
if "exif" in im.info:
exif_dict = piexif.load(im.info["exif"])
exif_dict["0th"][piexif.ImageIFD.ImageDescription] = message
exif_bytes = piexif.dump(exif_dict)
else:
exif_bytes = piexif.dump({"0th":{piexif.ImageIFD.ImageDescription:message}})
im.save("cover-secret.jpg", exif=exif_bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment