Created
April 1, 2013 08:13
-
-
Save Ripley6811/5283781 to your computer and use it in GitHub Desktop.
ccess EXIF data of images.
Preserve EXIF data after PIL manipulation of an image.
Requires exiftool.exe. Download from http://www.sno.phy.queensu.ca/~phil/exiftool/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Preserve EXIF data after PIL manipulation of an image. | |
Requires exiftool.exe. Download from http://www.sno.phy.queensu.ca/~phil/exiftool/ | |
Basically, do not save the manipulated image over the old image. Exiftool can | |
copy the data from old to new. | |
''' | |
from PIL import Image | |
import subprocess | |
exiftool = r'C:\...\exiftool.exe' # Path to exiftool.exe program | |
filename = r'C:\...\image.jpg' # Path to original image | |
savename = r'C:\...\image_new.jpg' # Destination for manipulated image | |
image = Image.open( filename ) | |
...# Manipulate image data | |
# Save image and copy EXIF from old to new | |
image.save( savename ) | |
subprocess.call([exiftool, | |
savename, | |
'-tagsFromFile', | |
filename], shell=True) | |
# Delete or rename old image as a backup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment