Author Topic: exiftool .Net wrapper (written in  (Read 34530 times)


  • Full Member
  • ***
  • Posts: 32
Re: exiftool .Net wrapper (written in
« Reply #30 on: November 23, 2019, 01:12:36 PM »
@saul: Just to be sure
Have you ever tried the ".Net wrapper for the excellent ExifTool" from Mike Morano?
Available as Nuget package. This one even offers a .GetTagsAsync which accepts a FilePath or IO.Stream.

@Curtis: No offense meant  :-X


  • Full Member
  • ***
  • Posts: 31
Re: exiftool .Net wrapper (written in
« Reply #31 on: February 13, 2020, 08:59:21 AM »
Hi Curtis
I'm trying to run a command which requires embedding a filename within the command itself:
sCmd = "-tagsfromfile """ & sJPEGFilename & """ -exif -makernotericoh -make -model -IFD0 "

For example, that becomes the following, which works fine from the command line:
-tagsfromfile "E:\Pictures\Incoming\Ricoh Theta\161121_RTH_0010233.jpg" -exif -makernotericoh -make -model -IFD0

I'm having great difficulty getting it to process correctly. I have tried wrapping the filename in double quotes, single quotes, double quotes prefixed by a backslash. All to no avail. Either the command returns with a blank result, or it just hangs.

What's the best way to include a filename to avoid this?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17499
    • ExifTool Home Page
Re: exiftool .Net wrapper (written in
« Reply #32 on: February 13, 2020, 09:21:27 AM »
Hi Andrew,

Does it work without quotes for files with no spaces in the file name?:

Code: [Select]
sCmd = "-tagsfromfile " & sJPEGFilename & " -exif -makernotericoh -make -model -IFD0"
- Phil

P.S. What is the -IFD0 for?  I don't think this will do anything.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).


  • Full Member
  • ***
  • Posts: 31
Re: exiftool .Net wrapper (written in
« Reply #33 on: February 25, 2020, 02:53:31 PM »
Hi Phil
With no quotes the command throws an exception:

Exception thrown: 'System.ArgumentOutOfRangeException' in System.Windows.Forms.dll
-tagsfromfile E:\Pictures\Incoming\Ricoh Theta\161122_RTH_0010236.jpg -exif -makernotericoh -make -model -IFD0

As I said, this works fine from the command line.


  • Full Member
  • ***
  • Posts: 31
Re: exiftool .Net wrapper (written in
« Reply #34 on: March 09, 2020, 01:23:23 PM »
I've cracked it. If you use the "tagsfromfile" or similar commands, then stdErr is awaiting input before the command can complete. If you run using "shell" or from the command line this is obvious, as there is a very obvious "Press Enter to continue prompt".

To get this to work you need to redirect stdInput and send it a blank line as input. Then when the command gets to the point where it needs the input, there's a buffered line waiting for it.

Here's my code which runs this. I suspect that the internal implementation of ExifToolIO is very similar, and if Saul can just add the two lines with the 'XXX comments then the problem will go away.
Code: [Select]
   Public Function RunProcess(sExecutable As String, sParameters As String, Optional sDirectory As String = "") As ProcessOutput
        ' Execute pricess in hidden window and capture output
            Dim oOutput As New ProcessOutput
            Dim pProcess As New System.Diagnostics.Process()            ' Create process
            pProcess.StartInfo.FileName = sExecutable                   ' Set executable and parameters
            pProcess.StartInfo.Arguments = sParameters
            pProcess.StartInfo.UseShellExecute = False                  ' Control execution visibility
            pProcess.StartInfo.CreateNoWindow = True
            pProcess.StartInfo.RedirectStandardOutput = True            ' Set outputs of program to be written to process output stream
            pProcess.StartInfo.RedirectStandardError = True
            pProcess.StartInfo.RedirectStandardInput = True               ' XXX Add This XXX
            If sDirectory <> "" Then pProcess.StartInfo.WorkingDirectory = sDirectory
            pProcess.Start()                                            ' Start the process
            pProcess.StandardInput.WriteLine("")                        ' XXX Complete processing, equivalent of pressing return to continue XXX
            pProcess.WaitForExit()                                      ' Wait for process to finish
            oOutput.StdOutput = pProcess.StandardOutput.ReadToEnd()     ' Read outputs
            oOutput.StdError = pProcess.StandardError.ReadToEnd
            Return oOutput
        Catch ex As Exception
        End Try
    End Function



  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4456
Re: exiftool .Net wrapper (written in
« Reply #35 on: March 09, 2020, 04:26:43 PM »
If you run using "shell" or from the command line this is obvious, as there is a very obvious "Press Enter to continue prompt".

Are you sure you haven't accidentally included the -k (pause) option?  Either directly in the command or as (-k) as part of the exiftool.exe name e.g exiftool (-k).exe?
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.


  • Newbie
  • *
  • Posts: 2
Re: exiftool .Net wrapper (written in
« Reply #36 on: November 10, 2020, 05:37:13 PM »
Longtime fan of ExifTool, first attempt to use it within another program.

I've created a small image watermarking program in VB2019 for others at my work. I load an image, it gets placed in a VB picturebox as a bitmap, the user can carry out minor alterations, and a watermark style is selected and added. While any supported image can be opened, it only saves in JPEG. As part of the save process, and 'in the background', I'd like to add in a standard line to the copyright field of the exif metadata. The bitmap in the picturebox is saved as a JPEG using a standard save file dialog.

I'm been playing around with the wrapper (least I think I have) and cannot seem to get it working with the image from the picturebox. I'm very novice at VB coding so I'm probably overlooking something.

I've tried converting the bitmap directly to a type that Visual Studio doesn't throw an error for but no luck, various errors halt the program at the execute commend. Some Googlefu has turned up bits and pieces, such as sending the bitmap through a memory stream, but I'm at a loss for even a starting spot.

Thanks everyone in advance!