Editing Exif of an image

Asked

Viewed 117 times

2

I need to edit the information exif of an image, such as location and date, for example, but I’m not able to find any library that does this with Python 3.4 and Windows. The most I got was using Pillow to read these properties, however, when I edit and try to save the image as follows:

image.save(path+'/teste.jpg', 'JPEG', exif=tags)

Where tags is a Dict, it says that the parameter Exif does not accept the type Dict, even because it is a binary. I recover Exif as follows:

tags = image._getexif()

If I try to save directly with this Exif, it will point out the same error, only if I use:

tags = image.info['exif']

I can use tags to save, however it comes in a format that is impossible to edit. So, is there any lib for Windows and Python 3 that solves this problem?

  • I think the Exifread may work in this case.

  • @qmechanik, the problem is that I can only read Exif, I can’t edit. ://

  • I suggest you take a look at gexiv2 (possesses bindings for Python, 2 and 3). I have never used, I can’t evaluate if it is good or not. Fountain :)

  • @mgibsonbr, I took a look at it, but from what I understand, it’s only for Unix based. : // The closest one so far has been pyexiv2 (which is a deprecated version of gexiv2), because it’s a function for Windows, but only python 2.x :/

1 answer

2


Apparently, a good option is piexif -

https://pypi.python.org/pypi/piexif/1.0.1

I did a quick test here, just installed and read the information from an image. The examples in the documentation show how to obtain the information and save it back using it in conjunction with the PIL.

The library is pure Python, independent of operating system - test on Pyhon 3.3 on 64bit Linux.

  • I’ll test, working it out, I accept the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.