edleafe / pyexif Goto Github PK
View Code? Open in Web Editor NEWPython module to read/write EXIF data for images
Home Page: http://leafe.com/projects/pyexif
License: Apache License 2.0
Python module to read/write EXIF data for images
Home Page: http://leafe.com/projects/pyexif
License: Apache License 2.0
Introduction ============ Images can contain **EXIF** metadata that describes information about the image, such as creation date, the device used to create the image, exposure data, GPS geotagging, keywords, compression, flash info, and lots more. In addition to the standard tags defined by camera manufacturers, you can also add your own tags with information as key/value pairs. NOTE: This module requires that the "exiftool" command-line tool is installed on the system running pyexif. It is freely available at: http://www.sno.phy.queensu.ca/~phil/exiftool/ If exiftool is not installed, a warning message will be printed to stdout, and the module will not work. Common Actions Please note that any of the write operations *immediately* affect the image file. Please operate on a copy of the original. Keyword Manipulation ==================== get_keywords(): returns a list of all keywords. set_keywords(list of keywords): accepts a list of strings, and sets the keywords for that image to that list. Any existing keywords are overwritten. add_keyword(word): Appends the passed keyword to the image's keywords. add_keyword(list of words): Convenience method for adding several keywords at once. clear_keywords(): Removes all current keywords. Date Functions ============== get_original_date_time(): Returns the datetime for the image's creation, or None if not set. set_original_date_time(dttm): Sets the image's original datetime to the passed datetime value. get_modification_date_time(): Returns the modification datetime for the image, or None if not set. set_modification_date_time(dttm): Sets the image's modification datetime to the passed datetime value. Image Manipulation ================== rotate_CW(num=1): Rotates the image clockwise for 'num' 90-degree steps. rotate_CCW(num=1): Rotates the image counter-clockwise for 'num' 90-degree steps. mirror_vertically(): Flips the image top to bottom. mirror_horizontally: Flips the image left to right. Tag Manipulation ================ get_tag(tag): returns the current value of the specified tag, or None if the tag does not exist. set_tag(tag, val): sets the specified tag to the specified value.
When using the setTag()
function inside a for loop(multiple files in a directory), I am getting the following error: "Warning: [minor] Entries in ExifIFD were out of sequence. Fixed". And the for loop halts for a while like 2-3 mins and then continues. Is there a fix to this or am I doing something wrong? Please find my code snippet below:
cwd=os.getcwd()
for f in sorted(os.listdir(cwd)):
try:
image = Image.open(f)
metadata = pyexif.ExifEditor(f)
exif = json.loads(metadata.getTag('UserComment'))
exif["header"]["device_id"]="m02-test"
exif_str = json.dumps(exif)
metadata.setTag('UserComment', exif_str)
The code published on PyPI appears to be version 0.9 instead of version 1.0 even though it is listed as version 1.0. I'm guessing that an out of date clone was mispackaged for the most recent release. Also, PyPI does not have a description or a link to the repository.
This is the stacktrace:
Traceback (most recent call last):
File "/Users/myuser/projects/album/main.py", line 23, in set_date
metadata.setTag('DateTimeOriginal', datestamp)
File "/Users/manuelo/projects/album/venv/lib/python3.9/site-packages/pyexif/pyexif.py", line 246, in setTag
out = _runproc(cmd, self.photo)
File "/Users/manuelo/projects/album/venv/lib/python3.9/site-packages/pyexif/pyexif.py", line 32, in _runproc
if (err.startswith("Warning: Bad ExifIFD directory")
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
The actual error reads something like
b'Warning: [minor] Ignored empty rdf:Bag list for Iptc4xmpExt:LocationCreated - picture.jpg\n'
Expect the ability to overwrite a tag. However, when I try to write to the tag, exiftool
returns the tag isn't available.
pyexif_img = pyexif.ExifEditor(photo=img_fname, save_backup=True)
pyexif_img.getTag('RigName')
Out[47]: 'SlantRange-3P'
In [49]: pyexif_img.setTag('RigName', 'Altum')
Traceback (most recent call last):
File "<ipython-input-49-6d449a342efc>", line 1, in <module>
pyexif_img.setTag('RigName', 'Altum')
File "Python Scripts\convert_sr\pyexif\pyexif\__init__.py", line 265, in setTag
out = _runproc(cmd, self.photo)
File "Python Scripts\convert_sr\pyexif\pyexif\__init__.py", line 50, in _runproc
raise RuntimeError(err)
RuntimeError: b"Warning: Tag 'RigName' is not defined\r\nNothing to do.\r\n"
Hello I hope you are well, I am having trouble understanding which directory pyexif looks inside. I am using windows 10 and have tried placing the file in C:/Windows, in the Library/bin for conda and then the C:/Users/me. Where is it supposed to be so that pyexif can find it?
Regards,
Oscar
I get a RuntimeError: Warning: [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto
on some of my photos. _runproc
raises on all "errors". Would it be possible to ignore all "Warnings" (as it is only a warning and no error)?
On the morning of Saturday, March 23, 2013, the 'rackspace' organization on GitHub will be reorganized. All repos will be moved to the new 'rackerlabs' organization, except for those that are designed to be used by Rackspace customers and which are fully supported.
Please update any links to this repo to reflect the new location within GitHub. For example, if the link to your repo is 'https://github.com/rackspace/foo', you need to change it to 'https://github.com/rackerlabs/foo'.
Body of message
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.