ExifTool Forum

ExifTool => Developers => Topic started by: Password! on May 21, 2013, 10:49:43 PM

Title: Changing exif meta data using textbox VB6
Post by: Password! on May 21, 2013, 10:49:43 PM
Hi to all,

Is there a way to change the exif meta data of an image?

I having a problem regarding exif meta data of image. I downloaded a exifreader tool to read and extract the meta data of an image appear in some textbox. if the image are lack of info(NO GPS Location) the textbox are leave blank. now what I want is to add the data(GPS Location) to the existing image and save it as JPEG file. (is this Possible?)

Private Sub Command1_Click()
If Picture1.Picture = 0 Then
MsgBox ("Insert Image First")
Else
Text6.Text = CommonDialog1.FileName
Text3.Enabled = False
Dim objexif As New ExifReader
    Dim txtExifInfo As String
    objexif.Load (Text6.Text)
    Text2.Text = objexif.Tag(GPSLongitude)
    Text3.Text = objexif.Tag(GPSLatitude)
    Text4.Text = objexif.Tag(GPSInfo)
    Text5.Text = objexif.Tag(DateTimeOriginal)
Text2.Enabled = False
Text6.Enabled = False
Text3.Enabled = False
End If
End Sub
(see attach file)

please help me for the editing of meta data.. this for my Graduation Thesis.. I would really appreciated whose willing to help.. and I also shared the code and knowledge to everyone if it is done.. thanks.. :)  ;) :)

jonel
Title: Re: Changing exif meta data using textbox VB6
Post by: Phil Harvey on May 22, 2013, 07:15:31 AM
You call exiftool from your VB6 application to change the EXIF metadata.

See the writing examples section of the exiftool application documentation (https://exiftool.org/exiftool_pod.html#writing_examples) for example exiftool commands.

See the Programming section of the ExifTool home page (https://exiftool.org/index.html#related_prog) for example VB6 code that calls exiftool.

- Phil
Title: Re: Changing exif meta data using textbox VB6
Post by: pws442 on June 25, 2014, 12:50:04 PM
I too, am using VB6, and having a difficult time creating a DLL that I can add as a reference in order to do the statement: "Dim objexif As New ExifReader" that is in the example. I have tried to follow the instructions in the links, to no avail. Can you please tell me how I can create this ell in VB6? Many thanks.
Title: Re: Changing exif meta data using textbox VB6
Post by: orax on June 25, 2014, 05:01:08 PM
I think class he used is http://sourceforge.net/projects/exifclass/ (http://sourceforge.net/projects/exifclass/)

Example in ZIP file seems to correspond:
Below is an example using this class in VB 6:

Dim objExif as New ExifReader
Dim txtExifInfo as String

objExif.Load "C:\Path_To_Jpg.jpg"
txtExifInfo = objExif.Tag(DateTimeOriginal)
MsgBox txtExifInfo
Title: Re: Changing exif meta data using textbox VB6
Post by: tpalmer0127 on July 19, 2014, 08:35:52 PM
I'm working with Michael Wandel's VB 6 code from this site.

I created a form, imported the .bas module.  I added a command button to the form and pasted the code to call EXIFLoad to the Command1_Click.

I'm having a couple of problems with the AppPath and FileExist functions that I bypassed with If True statements since I know exiftool and the image file do exist.

The code then does seem to work until a get an error in this section of code


                        If Trim(inText) <> "" Then
                                inArray = Split(inText, vbCrLf)
                                For I = 0 To UBound(inArray) - 1E
                                        exifStructure(exifLen, 1) = Trim(Left(inArray(I), InStr(inArray(I), ":") - 1))   '****************** ERROR ON THIS LINE
                                        exifStructure(exifLen, 2) = Trim(Mid(inArray(I), InStr(inArray(I), ":") + 1, Len(inArray(I))))
                                        exifLen = exifLen + 1
                                Next
                                exifLoaded = True
                        Else
                                exifFile = ""
                                exifLoaded = False
                        End If

The error is Invalid procedure call or argument.
Debug.print yields the following:
I =178
inArray(177) = FocalLenght35efl                 :  400.0 mm (35 mm equivalent: 600--GetConsoleMode failed, LastError=|6|  at Term/ReadKey.pm line 264.
inArray(178) = .0 mm

If I execute exiftool from the dos command, the tags look OK.  The last three tags are:
FocalLength35efl                : 400.0 mm (35 mm equivalent: 600.0 mm)
HyperfocalDistance              : 726.15 m
LightValue                      : 11.9

Any help would be appreciated.
Terry


Title: Re: Changing exif meta data using textbox VB6
Post by: Phil Harvey on July 19, 2014, 08:42:12 PM
Hi Terry,

I don't know anything about VB6, but the line you are having trouble with has 2 colons.  I suspect this may be part of the problem.

- Phil
Title: Re: Changing exif meta data using textbox VB6
Post by: tpalmer0127 on July 19, 2014, 10:04:26 PM
Thanks, Phil

It looks like there is an error message

"--GetConsoleMode failed, LastError=|6|  at Term/ReadKey.pm line 264."

being inserted into the data stream.  After this message is a CrLf (not the ":"  that pushes the .0 mm to the next inArray element. 

A quick Google search shows the GetConsoleMode failed ... is a Perl message

Terry
Title: Re: Changing exif meta data using textbox VB6
Post by: Hayo Baan on July 20, 2014, 02:55:17 AM
Error messgages should go to STDERR and stay separated from the normal output to STDOUT. It looks like your code is mixing the two, and worse seems to have one in buffered mode and another in unbuffered mode, causing the error message to appear somewhere in between the normal output. My guess is, the problem lies somewhere here. It is very very unlikely that it has anything to do with exiftool itself.
Title: Re: Changing exif meta data using textbox VB6
Post by: tpalmer0127 on July 20, 2014, 09:06:45 AM
Hayo

Not sure where I go from here.  I can hack the loop to bypass that array entry, but that is a very bad way to handle this.  The code that calls Exiftool was pulled from a link on this site and somewhat beyond my understanding.  I may try to contact the original programmer.

Thanks for your help.

Terry
Title: Re: Changing exif meta data using textbox VB6
Post by: Phil Harvey on July 20, 2014, 09:53:18 AM
Hi Terry,

If the error message is coming from Perl, then it must be due to an error writing stdout to the pipe somehow.  In this case, it is unrelated to the colon, and perhaps more likely due to the exiftool output exceeding the pipe buffer size somehow.  (Although I have never seen this problem.)  I'm not sure if you have control over the pipe buffer size, but if you do try increasing it.  I'm afraid I can't be much more help on this one.

- Phil
Title: Re: Changing exif meta data using textbox VB6
Post by: tpalmer0127 on July 20, 2014, 11:59:03 AM
Phil,

I'll take a look at that although as I said, I'm not very experienced in that area.  I did e-mail M Wandel, the author of that code and asked that he take a look at this thread.  Hopefully, he can shed some light on this problem.

Terry
Title: Re: Changing exif meta data using textbox VB6
Post by: orax on July 20, 2014, 12:23:02 PM
Hi Terry,

Do you have tested my example modEXIFTool.zip here ? https://exiftool.org/forum/index.php/topic,5891.msg29017.html#msg29017 (https://exiftool.org/forum/index.php/topic,5891.msg29017.html#msg29017)
I don't have any error. Tested on Win XP, with PNG, JPG and CR2.

inArray(177) = FocalLenght35efl                 :  400.0 mm (35 mm equivalent: 600--GetConsoleMode failed, LastError=|6|  at Term/ReadKey.pm line 264.
It's FocalLength35efl. Error in Exiftool ?
Title: Re: Changing exif meta data using textbox VB6
Post by: tpalmer0127 on July 20, 2014, 08:48:19 PM
Orax,

I'm doing pretty much the same thing that you are.

Just to be sure, I added the large multiline text box that you have in your project to my project and added the return value to the EXIFLoad function.  I still get the same results and in fact see the Perl error in the multiline text box.

I think that Phil and Hayo may be onto something with the STDOUT and STDERR and/or the pipe buffer size.  Hopefully, someone can point me in a good direction for a solution.

For now, I'm using and On Error goto that bypasses the two assignment statements that give me an error.

Thanks for your suggestion and sample code.

Terry
Title: Re: Changing exif meta data using textbox VB6
Post by: Phil Harvey on July 20, 2014, 08:51:59 PM
Quote from: orax on July 20, 2014, 12:23:02 PM
inArray(177) = FocalLenght35efl                 :  400.0 mm (35 mm equivalent: 600--GetConsoleMode failed, LastError=|6|  at Term/ReadKey.pm line 264.
It's FocalLength35efl. Error in Exiftool ?

Nope.  Cut+paste anomaly maybe.

- Phil
Title: Re: Changing exif meta data using textbox VB6
Post by: tpalmer0127 on July 21, 2014, 10:20:06 AM
inArray(177) = FocalLenght35efl                 :  400.0 mm (35 mm equivalent: 600--GetConsoleMode failed, LastError=|6|  at Term/ReadKey.pm line 264.
It's FocalLength35efl. Error in Exiftool ?

Actually, a typo.  I was using one PC to test my calls to Exiftool and another to look at documentation and post to this forum.  Rather than cut and past to a file on network drive, etc.   I just re-typed the information.

Terry
Title: Re: Changing exif meta data using textbox VB6
Post by: Skippy on August 23, 2015, 07:19:59 PM
@ pws442
Quote from: pws442 on June 25, 2014, 12:50:04 PM
I too, am using VB6, and having a difficult time creating a DLL that I can add as a reference in order to do the statement: "Dim objexif As New ExifReader" that is in the example. I have tried to follow the instructions in the links, to no avail. Can you please tell me how I can create this ell in VB6? Many thanks.
I am using ms-access and can't make a dll so I found another way that is easy for a VBA developer.  I used PureBasic to make a dll.  The dll only had about 6 lines of code in it and all of these lines were working code so it was not hard to do.  PureBasic compiles standalone executables so you can compile as standalone 32 bit or 64 bit dll file that will run on windows, Mac, Linux without needing the PureBasic program.  The dll I wrote was for pulling in XMP data. 

Also remember to use ptr safe (?) keyword in your call to the dll to make sure that your code will work if it is run in 64 bit mode.