Using exiftool from within my image editor?

Started by lost_dev, January 04, 2012, 03:04:37 PM

Previous topic - Next topic

lost_dev

Okay, apologies in advance for my lack of knowledge on the subject. I've created a working cross-platform image editor for OSX and Windows, but my output jpgs have no metadata. I simply want to copy any and all metadata from the source image into the edited jpg I'm saving out.

Is it a bad idea to use exiftool (calling the command line version from within my C++ code) for this purpose? I've googled and found some references on how to do this with exiftool, but it's a little complicated, and I'm wondering if it's overkill to use exiftool at all. (Not to mention licensing issues.) I'm not finding any obvious way to just copy the metadata when I'm reading a file in via Qt, but I could easily be missing something. Or is this in fact what exiftool is designed for?

I know it's a vague question, but any links/advice would be very much appreciated. Thanks!

Phil Harvey

#1
If you want to copy all metadata, then there aren't many applications/utilities that will be as thorough as ExifTool.  The disadvantage of calling exiftool would be in speed if processing a large number of images.  Startup overhead can be eliminated using the -stay_open feature, so speed with a small number of images shouldn't be an issue.

Licensing isn't an issue.  You can use exiftool free for this purpose.

But you probably don't want to just copy the metadata.  You should change things like the ExifImageWidth/Height and Orientation if they were changed when the image was edited.  Also, I am sure that once you get into this you will find other things you want to change/add (copyright notices for example).

There may be other solutions out there, but don't have any first hand experience with any of them, so I can't say if any of them would be easier for you to use than exiftool.

I'm thinking that at some point I may write a C++ interface for the application to act as an example/basis for developers to use.  I recently scratched out a proof of concept in Perl, but I haven't done anything for C++ yet.  There is a sample C++ wrapper available from the Exiftool home page, but I haven't played with this and I think it pre-dates the -stay_open feature.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

lost_dev

Fantastic. Many thanks for this clear and detailed response, and for creating such a powerful tool. It's looking like a true life-saver.

BogdanH

Hi,

I've tried to handle metadata in my code (not C++) and gave up. I would say, reading (some of) metadata is not that difficult, after metadata specifications are fully understood. But believe me: manipulating metadata can really hurt brains. Speaking for me, as long ExifTool exist, I will never ever write my own code for metadata editing!
Calling ExifTool from your own written application is relative simple and after you accomplish that, the whole metadata world will be in front of your eyes -and there will be nothing you can't do with metadata.

Phil mentioned speed... ok, there is some penalty, but I assume, that if your app is photo editing software in first place, then this shouldn't be a problem at all -I assume, not that many images will be open simultaneously. Btw. we are talking about milliseconds differences in this case.
And second, I've observed, that speed on large amount of files (hundreds, thousands) that ExifTool processes, isn't really limited that much by ExifTool. Especially on large files (say, over 15MB), OS needs some time to read them -as they are usually not "fully" cached (all the time).

Bogdan

lost_dev

Thanks Bogdan!

I'm up and running, works a treat.

Not sure if I mentioned that I'm intending to try selling this at some point. Just to be sure: could ExifTool be distributed and used in this way, as a command-line tool alongside a commercial application? I'd hate to do the wrong thing, and would be happy to license or whatever else might be necessary.

lost_dev

Sorry! Should have searched first: https://exiftool.org/forum/index.php?topic=3539.0