Created
February 13, 2014 23:11
-
-
Save saimn/8985911 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import io | |
from PIL import Image | |
from PIL import TiffImagePlugin | |
im = Image.open('tmp/test/in/1900-1910/00/joey.jpg') | |
exif = im._getexif() | |
data = im.info["exif"] | |
file = io.BytesIO(data[6:]) | |
head = file.read(8) | |
info = TiffImagePlugin.ImageFileDirectory(head) | |
info.load(file) | |
print info.items() | |
# modify orientation | |
info[0x0112] = (8,) | |
out = io.BytesIO() | |
info.save(out) | |
out.seek(0) | |
dat = out.read() | |
im.info["exif"] = data[:14] + dat + data[exif[0x8769]:] | |
im.save('tmp.jpg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment