如何在VB .NET中使用ExifWorks将数据从CSV文件添加到元数据照片? [英] How to add data from CSV file to metadata photo using ExifWorks in VB .NET ?

查看:79
本文介绍了如何在VB .NET中使用ExifWorks将数据从CSV文件添加到元数据照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是使用Vb .Net的新手.当我尝试使用ExifWorks将CSV文件中的数据添加/集成到元数据照片时,我遇到了一个问题.

Hi, I am newbie using Vb .Net. and i have a problem when i tried to add/integrate data from CSV file to metadata photo using ExifWorks.

这是我的代码:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim x, k As Integer
        Dim tgl, jam As String
        For x = 0 To PathFiles.Items.Count - 1
            Dim EW As New ExifWorks(PathFiles.Items.Item(x).ToString)
            For k = 0 To Tanggal.Items.Count - 1
                Tanggal.SelectedIndex = k
                Waktu.SelectedIndex = k
                AirSpeed.SelectedIndex = k
                GPSLatitude.SelectedIndex = k
                GPSLongitude.SelectedIndex = k
                GPSAltitude.SelectedIndex = k

                TextBox1.Text = EW.DateTimeOriginal.ToString()
                jam = TextBox1.Text.Substring(TextBox1.Text.Length - 8, 8)
                tgl = TextBox1.Text.Substring(0, 10)

                If tgl = Tanggal.SelectedItem Then
                    If jam = Waktu.SelectedItem Then
                        MsgBox("lll")
                        Dim str As String = AirSpeed.Items.Item(AirSpeed.SelectedIndex)
                        Dim byteArray(199) As Byte
                        Dim u(199) As Byte
                        Dim hexNumbers As System.Text.StringBuilder = New System.Text.StringBuilder
                        byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)
                        For i As Integer = 0 To byteArray.Length - 1
                            hexNumbers.Append(byteArray(i).ToString("x"))
                            u(i) = (byteArray(i))
                        Next
                        EW.SetProperty(65113, u, ExifWorks.ExifDataTypes.AsciiString)
                    End If

                End If
            Next
            PathFiles.SelectedIndex = x
            Sleep(1000)
        Next
    End Sub


 Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try
            Dim EX As New ExifWorks(PathFiles.Items.Item(PathFiles.SelectedIndex).ToString)

            Dim str As String = Tanggal.SelectedItem
            Dim byteArray(199) As Byte
            Dim hexNumbers As System.Text.StringBuilder = New System.Text.StringBuilder
            byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)

            For i As Integer = 0 To byteArray.Length - 1
                hexNumbers.Append(byteArray(i).ToString("x"))

            Next
            EX.SetProperty(65113, byteArray, ExifWorks.ExifDataTypes.AsciiString)
            'YANG BARU
            pic.Image = EX.GetBitmap() 
            Dim kk, oi As String
            kk = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\save.jpg"
            oi = Strings.Mid(kk, 7, kk.Length - 1)

            MsgBox(oi)
            Dim baru As Bitmap
            baru = EX.GetBitmap 

            baru.Save(oi) 
            EX.Dispose() 
        Catch ex As Exception

        End Try
        
    End Sub

实际上,我希望将数据从CSV文件集成到元数据照片中,这些数据包括风速,gps纬度,gps经度和高度. CSV文件包含大量数据. &path文件是指包含许多照片的文件夹.所以,要整合 两者,我必须使用两者的日期和时间进行同步.

actually, i want to integrate data of air speed, gps latitude, gps longitude and altitute from CSV file to metadata photo. CSV file contains of lots of data.  and pathfile refers to folder which contains of many photos. So, to integrate both of them, i have to synchronize them using date and time of both.

我设法同步了这些日期和时间.但是,问题是来自CSV文件的数据尚未导入到元数据照片中.

i've managed to synchronize those date and time. but, the problem is data from CSV file has not imported yet to the metadata photo.

我真的需要您的帮助来修复代码.对不起,英语不好.我希望你明白我的意思.

I really need your help to fix the code. Sorry for the bad english. I hope you understand what i mean.

此致

Intan

推荐答案

我设法同步了这些日期和时间.但是,问题是来自CSV文件的数据尚未导入到元数据照片中.

i've managed to synchronize those date and time. but, the problem is data from CSV file has not imported yet to the metadata photo.

什么是媒体资源ID 65113(0xFE59)? MS列表最多只能为0xA032.

What is property ID 65113 (0xFE59)?  The MS list only goes up to 0xA032.

https://msdn.microsoft.com/en-us/library/ms534416(v = vs.85).aspx

如果该属性的格式为ASCIIString,那么您应该传递一个ASCII字节数组.您的代码似乎创建了一个十六进制值字符串.但是无论如何,GPS数据都是字符串类型和有理数类型.另外,您必须检查 在添加或更新GPS数据之前,存在ID为0x0000且值为0x02000000的属性.

If the format for that property is ASCIIString then you should be passing an array of ASCII bytes.  Your code seems to create a string of hex values.  But in any case the GPS data is type string and type rational.  Also, you must check that a property with ID 0x0000 and value 0x02000000 exists before adding or updating GPS data.

您应该编写示例例程,以从您知道包含该数据的图像中获取GPS数据.在这种情况下,您可以向后进行操作,以将相同数据放回不同的图像中,然后进行调整,以便可以将任何数据放到 图片.

You should write an example routine to get the GPS data out of an image that you know contains this data.  When that is working you can work backwards to put the same data back into a different image, then adjust that so you can put any data into an image.


这篇关于如何在VB .NET中使用ExifWorks将数据从CSV文件添加到元数据照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆