exiftool .Net wrapper (written in vb.net)

Started by Curtis, June 09, 2014, 05:31:48 PM

Previous topic - Next topic

StarGeek

Yeah, the link appears dead and it doesn't look like it's been copied to another source and no sign of it in the Wayback Machine.  The post just above yours appears to have been the last post by Curtis.

You might try google for something similar.  I saw at least one other .net exiftool wrapper out there (NExifTool) though no idea how well it works.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Curtis

Tom,
Yes, that link is likely no longer good.
Best to just DL the source code  from original post. 
As far as the getting the shutter count I'm not familiar with the tag that would give you the shutter count. But if you know the tag name, then yes you should be able to get the value.
I have not actively worked on that code for quite a while, but if you have some specific questions, I'll do my best to answer.
Curtis

photos

Hi Curtis,

Thanks for the response.  I managed to edit the project files to open the code in VS2010.  Looking at your code and a few trial and error tests found the shutter count in the maker notes, which for the Nikon cameras is under the Nikon TAG.  So;


                ExifToolIO.Initiailize()
                ExifToolIO.Cmd("-Nikon:ShutterCount")
                Dim tmpstr As String = ExifToolIO.Execute(ImageName)
                lblShutter.Text = tmpstr
                ExifToolIO.Close()


worked perfect for me.  Thanks for all of your efforts on your wrapper it looks to be very detailed.  It took five days of searching and many tests to get to a point which I though should only take a couple of hours :)
I had no idea how deep the water was.  Thanks again Curtis.

Curtis

Tom,
Glad you got it to work under VS 2010. I think you can download VS 2015 and 2017 for free... they have some nice new features.
Curtis

gkinney

Hello Cutis, I know this is an old thread. I cannot get Windows 10 to allow the writing. I can do it in dos no problem. Any clue? If you even can remember your tool?

Thanks!

Curtis

Hi gkinney,
I don"t have a Windows 10 machine, only Windows 7, so I can't try to replicate your problem.  I don't understand if you have used my tool and it worked and if so on what kind of system? or ??  .Net I don't think runs under DOS?!.

If you can tell me more what you have tried I may be able to help...
Curtis

gkinney

Hello Curtis, My apologies. I am using Visual Studio Community 2017. Version 15.9.15 on Windows 10 PRO

What I am seeing is that my app reads the tags I need (IPTC:Keywords) fine.
Then at some point, it stops allowing me to update the keywords in the file.  (Ive done it several times with ExifTooolIO from my project) and ExifTool.exe

However, I may be on to something!

I just caused an error when I selected a folder with no files and got an exception error selecting an item in a list control that was null. (my mistake) Hower now im seeing the rename error below. So this may be related to a locked file, or some other windows issue? Im looking at that now.

Attached is what I get when I know I am in fail mode:

Ill report back when I find a solution.

Thank you for your reply!



StarGeek

Error renaming temp files are usually caused by something having a lock on the original file.  The way exiftool works is that it creates a temporary file with the updates to the metadata, deletes the original, and renames the temp file.  If some program has the original file open for reading/writing, then the file can't be deleted and the temp file can't be renamed.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Curtis

What StarGeek said is correct.  That error message originates from ExifTool, not a problem with exiftoolio.

I noticed the file name you get the error on is:  C:/Gray/testfile.jpg
should the '/' be '\' ??  Not sure if that is a problem.

Opps... I just remembered I think ExifTool changes the \ to /  internally .. so all should be OK with that it just shows the / in the error message from ExiftTool....

PS: I use Unlocker to unlock locked files... really has helped me a lot in many situations.  Worth a try... it is here:
https://www.softpedia.com/get/System/System-Miscellaneous/Unlocker.shtml

gkinney

Curtis and Stargeek Thanks for your reply!

I was on the same path as the locked file, I just couldn't figure out why?

I FINALLY figured it out. I wrote this app and had a picture control in it to view the image. I loaded the image in the control and then read the keywords. I then did a save on the keywords and then would get the lock error. I suddenly realized, that MAYBE the file loaded by the pic control may be locking the file. BINGO! When I removed the file from being loaded in the pic control, the problem went away!

Thanks to everyone that jumped in here and sorry for the hassle. But may help the next person?

Have a great day!

saul

Hi
Background: I have a C# / .Net application called Timelapse (http://saul.cpsc.ucalgary.ca/timelapse/) which biologists use to inspect and encode data describing thousands / millions of wildlife images captured by camera traps. Timelapse also allows the biologist to specify particular metadata fields that should be added to their data.

The issue is how to quickly extract the metadata field value in bulk over tens or even hundreds of thousands of images at a time.

I have used ExifToolWrapper in the past, but the current version of my system uses Drew Noak's Metadata extractor as it is an integrated dll (https://github.com/drewnoakes/metadata-extractor).

However, I was going to switch back to ExifTool (as it is much better at reading in makernotes from various cameras) but decided to run a speed test first.  (I can post / email the source for the test program if desired).

The time to extract the same metadata field over 1000 images is:
- ExifTool (using the ExifToolWrapper https://github.com/brain2cpu/ExiftoolWrapper): ~6.7 seconds
- MetadataExtractor: ~0.23 seconds
This is obviously a significant difference, and it can have huge impact on my users processing massive photo numbers.

Three questions
1. Are there other wrappers other than ExifToolWrapper that are faster and/or better that you can recommend?
3. Is the inefficiency in ExifTool, or in how ExifToolWrapper invokes it?
2. If you are familiar with ExifToolWrapper, is there a better way to get it to extract metadata fields aside from iterating over each file using MetadataExtractorGetFieldValue  - note that I am using exifTool.Start() before the loop, so I am just using one process vs. restarting ExifTool for every iteration.

StarGeek

I'm not sure how much help can be found here though there may be a few users who might chime in.  There haven't been too many questions along these lines over the years. 

What I can say is that exiftool is still a Perl application.  The Windows "executable" is, at it's heart, the Perl code packed with a minimal Perl interpreter.  There are going to be limitations compared to a purely compiled metadata extractor.

Any more details may have to wait until sometime next week, as Phil is currently away.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Curtis

Saul,
Have you tried the .net wrapper I wrote? (see first post on this thread) I have not used it lately, but as I recall it is much faster than taking 6.7 sec for 1,000 images.  Would be a very short C# or vb.net program to try that out with my wrapper. 

Also, I have a version that is multi threaded and will use up to all of the cores that you have to process the images.  I have not made this version available here as it is more complicated and few people had the need for that.

I'm traveling now so I don't have access to that code, but if you try my existing code and if it seems like it could work for you then I could possibly get the multi threaded version code to you later.

HTH,
Curtis

saul

Thanks Curtis - I'll give this a shot and will get back to you. That multi-threaded version sounds very promising too, especially because its not unusual to have people trying to extract metadata from tens of thousands of images at a time.

saul

Hello Curtis
dI just ran your program to test it against MetadataExtractor  and ExiftoolWrapper. Unfortunately, its slower: about 16 seconds vs ExifToolWrapper to extract a field from 1000 images (vs .~.2 secs for metadataExtractor).

For coding, I invoked (according to the documentation in your post):
-ExifToolIO.Initiailize();
-Iterated over (sorta pseudocode)
     for each path in paths
            ExifToolIO.Cmd(-IFD0:Make);
            return ExifToolIO.Execute(path);
-ExifToolIO.Close()

Another reply to my post suggests its an inherent performance limitation due to ExifTool being a Python program. I should test the raw ExifTool program to see how it performs as that would be the 'best result' I could get with it, where I could then compare it with the wrapper overhead.

FYI, My current workaround is to provide both MetadataExtractor and ExifToolWrapper to the user as a choice. If the desired metadata field is displayed using MetadataExtractor, then that is the way to go as it is fast. If not, they can use ExifToolWrapper to see if the desired metadata field is there, and if so use that along with a performance penalty. Not the best solution, but it seems to work.