Changing exif meta data using textbox VB6

Started by Password!, May 21, 2013, 10:49:43 PM

Previous topic - Next topic

Password!

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

Phil Harvey

You call exiftool from your VB6 application to change the EXIF metadata.

See the writing examples section of the exiftool application documentation for example exiftool commands.

See the Programming section of the ExifTool home page for example VB6 code that calls exiftool.

- 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 ($).

pws442

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.

orax

I think class he used is 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

tpalmer0127

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



Phil Harvey

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
...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 ($).

tpalmer0127

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

Hayo Baan

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.
Hayo Baan – Photography
Web: www.hayobaan.nl

tpalmer0127

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

Phil Harvey

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
...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 ($).

tpalmer0127

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

orax

Hi Terry,

Do you have tested my example modEXIFTool.zip here ? 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 ?

tpalmer0127

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

Phil Harvey

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
...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 ($).

tpalmer0127

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