Skip to content

Instantly share code, notes, and snippets.

@zoomacode
Created January 9, 2014 08:55
Show Gist options
  • Save zoomacode/8331337 to your computer and use it in GitHub Desktop.
Save zoomacode/8331337 to your computer and use it in GitHub Desktop.
import Quartz
import CoreFoundation as CF
import os, sys
filename = os.path.abspath(sys.argv[1])
url = CF.CFURLCreateFromFileSystemRepresentation(None, filename, len(filename), False)
img_src = Quartz.ImageIO.CGImageSourceCreateWithURL(url, {})
properties = Quartz.ImageIO.CGImageSourceCopyPropertiesAtIndex(img_src, 0, None)
exif = properties[Quartz.ImageIO.kCGImagePropertyExifDictionary]
img_dest = Quartz.ImageIO.CGImageDestinationCreateWithURL(url, 'public.jpeg', 1, None)
exif[Quartz.ImageIO.kCGImagePropertyExifDateTimeOriginal] = u'2009:06:17 21:03:18'
Quartz.ImageIO.CGImageDestinationAddImageFromSource(\
img_dest, img_src, 0, {Quartz.ImageIO.kCGImagePropertyExifDictionary: exif})
Quartz.ImageIO.CGImageDestinationFinalize(img_dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment