Here is an inelegant and clumsy but working solution. There's apparently another package PIL from which Pillow was forked. Processing PNG files doesn't seem to be part of the package at all. Reading through the overall Pillow documentation, it really only talks about JPG and TIFF. _getexif feature is experimental and only applies to JPGs. The problem is, AttributeError: 'PngImageFile' object has no attribute '_getexif'. This reads in the image, but im.info only returns Maybe it just doesn't have the functionality I need?įollowing the advice given in this post: from PIL import Image Matroska video Microsoft RIFF (AVI video, WAV audio, CDA file) PNG As far as I can tell, those seem to be the two options for parsing PNG metadata. I've had no luck with other methods, such as metadata.get. I can't seem to get at the field I need, the "Settings" one referenced in the R code. Using the hachoir3 package, I tried the following: from hachoir.parser import createParserįrom tadata import extractMetadataįilename = "C:\\path\\to\\file\\image.png" However, it's still unclear how to extract the zTXt data. Examining the length of each chunk, it seems likely the "Settings" tag lives in the zTXt chunk. How can I extract PNG metadata using Python? Or doing so requires me to have far more knowledge of Python and PNGs than I have at the moment. It doesn't look like Python can do it, which boggles my mind. X = read_exif(file.path(path,'image.png')) Getting the metadata in R is incredibly easy: library(exifr) This tag contains XML which will then need to be parsed. I need the contents of a single tag called "Settings". I am able to extract the necessary information using R, but for consistency within the overall project, I would like to be able to do it with Python (preferably Python3).
0 Comments
Leave a Reply. |