-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move getxmp() to JpegImageFile #5376
Conversation
Thanks! I was going to add something like this to "API Additions" in the release notes, let's include it here? Image.getxmp
^^^^^^^^^^^^
A new method has been added to return an object with tag names and values to make it
easier to find what you're looking for, instead of giving the tag number to
:py:meth:`~PIL.Image.Image.getexif`.
For example::
>>> from PIL import Image
>>> with Image.open("xmp_test.jpg") as im:
>>> print(im.getxmp())
{'RDF': {}, 'Description': {'Version': '10.4', 'ProcessVersion': '10.0', 'ConvertToGrayscale': 'False', 'CameraProfile': 'Adobe Standard', 'LookTable': 'E1095149FDB39D7A057BAB208837E2E1'}, 'History': {}, 'Seq': {}, 'li': {}, 'DerivedFrom': {'documentID': '8367D410E636EA95B7DE7EBA1C43A412', 'originalDocumentID': '8367D410E636EA95B7DE7EBA1C43A412'}, 'ToneCurve': {}, 'ToneCurveRed': {}, 'ToneCurveGreen': {}, 'ToneCurveBlue': {}, 'ToneCurvePV2012': {}, 'ToneCurvePV2012Red': {}, 'ToneCurvePV2012Green': {}, 'ToneCurvePV2012Blue': {}, 'RetouchAreas': {}, 'Masks': {}, 'RetouchInfo': {}, 'Look': {}, 'Group': {}, 'Alt': {}, 'Parameters': {}} |
I've added release notes - it's different from your version though. It isn't actually pulling data from >>> from PIL import Image
>>> im = Image.open("Tests/images/xmp_test.jpg")
>>> im.getxmp()
{'RDF': {}, 'Description': {'Version': '10.4', 'ProcessVersion': '10.0', 'ConvertToGrayscale': 'False', 'CameraProfile': 'Adobe Standard', 'LookTable': 'E1095149FDB39D7A057BAB208837E2E1'}, 'History': {}, 'Seq': {}, 'li': {}, 'DerivedFrom': {'documentID': '8367D410E636EA95B7DE7EBA1C43A412', 'originalDocumentID': '8367D410E636EA95B7DE7EBA1C43A412'}, 'ToneCurve': {}, 'ToneCurveRed': {}, 'ToneCurveGreen': {}, 'ToneCurveBlue': {}, 'ToneCurvePV2012': {}, 'ToneCurvePV2012Red': {}, 'ToneCurvePV2012Green': {}, 'ToneCurvePV2012Blue': {}, 'RetouchAreas': {}, 'Masks': {}, 'RetouchInfo': {}, 'Look': {}, 'Group': {}, 'Alt': {}, 'Parameters': {}}
>>> dict(im.getexif())
{296: 2, 34665: 222, 271: 'Canon', 272: 'Canon EOS Rebel T6', 305: 'Adobe Photoshop Lightroom Classic 7.4 (Macintosh)', 306: '2018:10:27 16:20:29', 282: 300.0, 283: 300.0} In the last half hour, I've figured out what's going on, and I'm writing this partly for my future self. If you look at https://en.wikipedia.org/wiki/Extensible_Metadata_Platform#Embedding, XMP data can be stored in multiple locations
We do use "XML:com.adobe.xmp" internally elsewhere in Pillow at one point. The code in this method is just for JPEG images though. We could make this method read data more generally in the future, but that is not for today. |
Great, thanks! |
Follow up to #5144
Moved
getxmp()
from Image to JpegImageFile, since the method fetches data fromapplist
, which is a JpegImageFile property. Calling this method on a non-JPEG image would have caused an error.