Click here to Skip to main content
15,910,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, i'm trying to write to an images keywords/tags using ExifWorks. But it won't write, below is my code and i'm not sure what's wrong.
Public Class EXIFtest



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim text2 As String = TextBox2.Text
        Dim text3 As String = Replace(text2, ".jpg", "")
        Dim ef As New ExifWorks(text2)
        Dim imgWithExif As Image = ef._Image
        ef.Keyword = TextBox1.Text
        imgWithExif.Save(text3 + "TAGGED.jpg")
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click


        TextBox2.Text = ("C:\Users\Simon\Music\Pictures\Exif Tests\DSC_1847.jpg")
        PictureBox2.ImageLocation = TextBox2.Text



    End Sub

    Private Sub EXIFtest_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        TextBox2.Text = PictureBox2.ImageLocation
    End Sub
End Class

Is the main program

I've added to ExifWorks the below

Public Property Keyword() As String
       Get
           Return Me.GetPropertyString(TagNames.Keyword)
       End Get
       Set(ByVal Value As String)
           Try
               Me.SetPropertyString(TagNames.Keyword, Value)
           Catch ex As Exception
           End Try
       End Set
   End Property

VB
SB.Append("\n\tKeyword:   " & Me.Keyword)

and
Public Enum TagNames As Integer
       ExifIFD = &H8769
       GpsIFD = &H8825
       NewSubfileType = &HFE
       SubfileType = &HFF
       ImageWidth = &H100
       ImageHeight = &H101
       BitsPerSample = &H102
       Compression = &H103
       PhotometricInterp = &H106
       ThreshHolding = &H107
       CellWidth = &H108
       CellHeight = &H109
       FillOrder = &H10A
       Keyword = &H9C9E


I'm trying to add to the image property, tags. But it isn't working, any suggestions


VB
Imports Microsoft.ImageMetadata
Imports Microsoft.PhotoToolboxFoundation

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim text2 As String = TextBox2.Text
        Try 'This seems to work. look at the image noted in img_path.
            Dim img_path As String = "C:\Users\Simon\Music\Pictures\Exif Tests\DSC_1847.jpg"
            Dim p As MetadataPolicy = (New MetadataPolicyManager()).loadPolicy("C:\Users\Simon\Documents\Visual Studio 2010\Projects\EXIFtest\EXIFtest\Microsoft.PhotoToolboxFoundation.ToolboxPolicy.xml")
            Dim imgProxy As ImageFileProxy = New ImageFileProxy(img_path, p)
            Dim desc As Object = imgProxy.Data(p.getTagIndex("Description"))
            imgProxy.Data(p.getTagIndex("Description")) = "This is a test description for the jpg!"
            TextBox1.Text = ("Description: " + desc.ToString())
            imgProxy.commit()
        Catch ex As Exception
            MessageBox.Show(ex.Message, ErrorToString)
        End Try

    End Sub


What I have tried:

I've tried adding the hex and identifiers to the original class.
Posted
Updated 9-Sep-16 7:42am
v2

VB.NET Retrieving Meta Tags from an Image - Stack Overflow[^]
Explained it beautifully and my original idea of using ExifWorks was along the right lines.
Thank you Sergey for helping me find the right question i'm trying to ask. :)
 
Share this answer
 
Please see this CodeProject article: ExifLibrary for .NET[^].

—SA
 
Share this answer
 
Comments
Sdolby 7-Jun-16 13:05pm    
I've had a look, but it doesn't seem to talk about the specific part i'm looking at.
I'll link a photo to show you what i'm trying to edit.
Photo[^]
Sergey Alexandrovich Kryukov 7-Jun-16 13:20pm    
Do you mean that you did not find the support for Exif keyword/tags?
—SA
Sergey Alexandrovich Kryukov 7-Jun-16 13:26pm    
Here is the thing: I took one image on the top as a sample and examined it.
To my surprise, I did not find Exif info at all (never saw such things; was it wiped out before publishing?!)
It has only IPTC metadata, but no keywords/categories are filled in.
Are you sure you need Exif support, not IPTC?
See also Solution 3.
—SA
Sdolby 7-Jun-16 13:36pm    
Yes I didn't find the support for the keyword/tags
I'll have a play around tonight and tomorrow and see what I find. Thank you. :)
Sergey Alexandrovich Kryukov 7-Jun-16 13:41pm    
Very good. You are very welcome.
—SA
The image I downloaded from your source surprised me a bit. Please see my comment to the Solution 1.

This is another suggestion: please see this open-source library with Exif, IPTC, XMP, and ICC support: GitHub — drewnoakes/metadata-extractor-dotnet: Extracts Exif, IPTC, XMP, ICC and other metadata from image and movie files.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900