tags:

views:

461

answers:

3

If I were to tag a bunch of images via XMP, in Python, what would be the best way? I've used Perl's Image::ExifTool and I am very much used to its reliability. I mean the thing never bricked on tens of thousands of images.

I found this, backed by some heavy-hitters like the European Space Agency, but it's clearly marked as unstable.

Now, assuming I am comfortable with C++, how easy is it to, say, use the Adobe XMP toolkit directly, in Python? Having never done this before, I am not sure what I'd sign up for.

Update: I tried some libraries out there and, including the fore mentioned toolkit, they are still pretty immature and have glaring problems. I resorted to actually writing an Perl-based server that accepts XML requests to read and write metadata, with the combat-tested Image::EXIF. The amount of code is actually very light, and definitely beats torturing yourself by trying to get the Python libraries to work. The server solution is language-agnostic, so it's a twofer.

+3  A: 

Well, they website says that the python-xmp-toolkit uses Exempi, which is based on the Adobe XMP toolkit, via ctypes. What I'm trying to say is that you're not likely to create a better wrapping of the C++ code yourself. If it's unstable (i.e. buggy), it's most likely still cheaper for you to create patches than doing it yourself from scratch.

However, in your special situation, it depends on how much functionality you need. If you just need a single function, then wrapping the C++ code into a small C extension library or with Cython is feasible. When you need to have all functionality & flexibility, you have to create wrappers manually or using SWIG, basically repeating the work already done by other people.

Torsten Marek
Right, I definitely do not want to compete with the European Space Agency :) but I am wondering if it's a shortcut to use the Adobe toolkit directly. My purposes are VERY limited. Just writing some simple tags - no fancy stuff.
Andrei Taranchenko
In this case, I'd say simply write a small extension module.
Torsten Marek
@Torsten or just try the python-xmp-toolkit. "unstable" is vague, and it will probably do what he needs it to. only way to find out is to try..
Daniel
A: 

You can use ImageMagic convert, IIRC there's a Python module to it as well.

lazy1
A: 

I struggled for several hours with python-xmp-toolkit, and eventually gave up and just wrapped calls to ExifTool.

There is a Ruby library that wraps ExifTool as well (albeit, much better than what I created); I feel it'd be worth porting it to Python for a simple way of dealing with XMP.

Xiong Chiamiov