20minutes / iptcinfo Goto Github PK
View Code? Open in Web Editor NEWA Python port of Josh Carter's IPTCInfo (Perl)
Home Page: https://bitbucket.org/gthomas/iptcinfo
A Python port of Josh Carter's IPTCInfo (Perl)
Home Page: https://bitbucket.org/gthomas/iptcinfo
IPTCInfo: extract and modify IPTC (metadata) information on images - port of IPTCInfo.pm by Josh Carter <[email protected]>' Ported from Josh Carter's Perl IPTCInfo-1.9.pm by Tamas Gulacsi Ever wish you add information to your photos like a caption, the place you took it, the date, and perhaps even keywords and categories? You already can. The International Press Telecommunications Council (IPTC) defines a format for exchanging meta-information in news content, and that includes photographs. You can embed all kinds of information in your images. The trick is putting it to use. That's where this IPTCInfo Python module comes into play. You can embed information using many programs, including Adobe Photoshop, and IPTCInfo will let your web server -- and other automated server programs -- pull it back out. You can use the information directly in Python programs, export it to XML, or even export SQL statements ready to be fed into a database. 1.9.5-3: use logging module. 1.9.5-2: Emil Stenström pinpointed some bugs/misleading (un)comments Also a new (mis)feature is implemented: if you don't specify inp_charset (and the image misses such information, too) than no conversion is made to unicode, everything stays bytestring! This way you don't need to deal with charsets, BUT it is your risk to make the modifications with the SAME charset as it is in the image! 1.9.5-1: getting in sync with the Perl version 1.9.5 1.9.2-rc8: charset recognition loosened (failed with some image out of Adobe Lightroom). 1.9.2-rc7: NOT READY IPTCInfo now accepts 'inp_charset' keyword for setting input charset. 1.9.2-rc6: just PyLint-ed out some errors. 1.9.2-rc5: Amos Latteier sent me a patch which releases the requirement of the file objects to be file objects (he uses this on jpeg files stored in databases as strings). It modifies the module in order to look for a read method on the file object. If one exists it assumes the argument is a file object, otherwise it assumes it's a filename. 1.9.2-rc4: on Windows systems, tmpfile may not work correctly - now I use cStringIO on file save (to save the file without truncating it on Exception). 1.9.2-rc3: some little bug fixes, some safety enhancements (now iptcinfo.py will overwrite the original image file (info.save()) only if everything goes fine (so if an exception is thrown at writing, it won't cut your original file). This is a pre-release version: needs some testing, and has an unfound bug (yet): some pictures can be enhanced with iptc data, and iptcinfo.py is able to read them, but some other iptc data readers will spit on it. 1.9.1: a first release with some little encoding support The class IPTCInfo now has an inp_charset and an out_charset attribute - the first is the read image's charset (defaults to the system default charset), the second is the charset the writer will use (defaults to inp_charset). Reader will find the charset included in IPTC data (if any, defaults to the system's default charset), and use it to read to unicode strings. Writer will write using IPTCinfo.out_charset (if it is not set, will not write charset IPTC record). With this, it is possible to read and write i18n strings correctly. I haven't tested this functionality thoroughly, and that little test was only on my WinXP box only, with the only other IPTC reader: IrfanView. SYNOPSIS from iptcinfo import IPTCInfo import sys fn = (len(sys.argv) > 1 and [sys.argv[1]] or ['test.jpg'])[0] fn2 = (len(sys.argv) > 2 and [sys.argv[2]] or ['test_out.jpg'])[0] # Create new info object info = IPTCInfo(fn) # Check if file had IPTC data if len(info.data) < 4: raise Exception(info.error) # Print list of keywords, supplemental categories, contacts print info.keywords print info.supplementalCategories print info.contacts # Get specific attributes... caption = info.data['caption/abstract'] # Create object for file that may does have IPTC data. # info = IPTCInfo(fn) # for files without IPTC data, use info = IPTCInfo(fn, force=True) # Add/change an attribute info.data['caption/abstract'] = 'Witty caption here' info.data['supplemental category'] = ['portrait'] # Save new info to file ##### See disclaimer in 'SAVING FILES' section ##### info.save() info.saveAs(fn2) #re-read IPTC info print IPTCInfo(fn2)
seems this is an aged copy of https://bitbucket.org/gthomas/iptcinfo/downloads
the changes made on bitbucket.org seem not to be included here.
what's the purpose of this repos?
IPTC info works great but there are some fields that are part of IPTC core and are present in the image but still not fetched by IPTCInfo. One example is the Title field. Are there any plans to extend this module to include at least all the IPTC core fields?
For example the numeric code for title is 64 but is not present in the code mapping dict here: https://github.com/20minutes/iptcinfo/blob/master/iptcinfo.py#L323
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.