LeoHsiao1 / pyexiv2

Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.
GNU General Public License v3.0
196 stars 39 forks source link

API makes it hard to save the file elsewhere #93

Closed mixmastamyk closed 2 years ago

mixmastamyk commented 2 years ago

I'd like to save my changes to a temp file first before overwriting the original, I think that is safer. But the API seems to operate directly on the file. Would like a img.save('new_file.jpg') for example.

Wondered if you had any ideas to work with the library? To work around, I guess I'll have to make a copy first and then work on it.

LeoHsiao1 commented 2 years ago

Hi there. Exiv2 does not provide methods like img.save('new_file.jpg'). Exiv2 modifies the metadata through methods readMetadata() and writeMetadata(). It does not read the display content of the image. Therefore, The speed of reading metadata is inversely proportional to the amount of metadata, regardless of the size of the image. That's an advantage, isn't it? You have a good idea: make a copy of the image before modifying it.

mixmastamyk commented 2 years ago

It's good to have performance as an option, it's just that I'd prefer safety for any application with my photos. Would be nice if both strategies were available without jumping thru hoops. With the current functionality, I think the Image class for example, is misnamed. Because it only appears to concern itself with the metadata. I understand you didn't create the base library, so probably don't have motivation to change or work around it.

Anyway, thanks for the project. It seems the most mature of those I've tried. Modifying one of my test images resulted in almost zero extra changes to the file, which is what I'm also looking for.

LeoHsiao1 commented 2 years ago

Indeed, although the class name is Image, it only reads metadata, not the entire Image.