Image caption

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • umeshj99
    New Member
    • May 2007
    • 11

    Image caption

    Hello! I want to know how to retrieve image caption using .NET. I have collected some information about IPTC and exif tags. I have a function where it retrieves image caption stored in tag 10e. However, this code does not work for many of the images. Please help.

    Public Function displaydetails( ByVal img1 As String)
    Dim s As String
    Dim i As Integer
    Dim j As Integer
    Dim encoding As System.Text.Enc oding = System.Text.Enc oding.UTF8
    Dim aprop As PropertyItem
    Dim img As Image
    img = New Bitmap("c:\blan k1.jpg")
    s = " "
    Try
    img = New Bitmap(img1)
    ''''''start actual process here''''''''
    i = 0
    j = 0
    s = ""
    For Each aprop In img.PropertyIte ms
    If aprop.Id.ToStri ng("x") = "10e" Then
    s = Trim(encoding.G etString(aprop. Value))
    Exit For
    End If
    Next

    If s = "" Then
    s = " "
    End If
    Catch
    End Try

    Return s
    ''''''end actual process here''''''''''
    End Function
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Maybe there is not a caption for all images? None of my pictures had it.

    Also, are you sure the value is kept in UTF8 and not ASCII?

    Comment

    • umeshj99
      New Member
      • May 2007
      • 11

      #3
      Originally posted by Plater
      Maybe there is not a caption for all images? None of my pictures had it.

      Also, are you sure the value is kept in UTF8 and not ASCII?
      Thanks for the reply.

      I have opened the photo in adobe and seen that there is a caption. I have also tried using ASCII in place of UTF8. But still it doesn't show caption for some images.

      I feel some camera models may be storing caption at some other location and not at tag 10e. But .net PropertyItem property of image objects gives access to only 5 to 6 tags. So there should be a method to retrieve all tags of the image. Then we may be able to retrieve caption by doing some R&D on which camera model stores tag at which place.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I looked at a number of pictures I had and there was only two property items. One would say like "Adobe" something or other, and the other property item would be like 4k. Which makes me think there are more proporties burried inside it?

        Also, if there are \0 characters in your propertyitem value data, the string gets mangled. You might want to manually piece together the byte[] into a string to see if that helps?

        Comment

        • umeshj99
          New Member
          • May 2007
          • 11

          #5
          Originally posted by Plater
          I looked at a number of pictures I had and there was only two property items. One would say like "Adobe" something or other, and the other property item would be like 4k. Which makes me think there are more proporties burried inside it?

          Also, if there are \0 characters in your propertyitem value data, the string gets mangled. You might want to manually piece together the byte[] into a string to see if that helps?

          In the code which I have pasted, img.propertyite ms returns collection of 5 to 6 properties. Also, from search in google, I have come to known that there are so many exif and IPTC tags.

          Regarding \0 characters and manually pieceing together the byte[] into a string, I don't know how to do that.


          Thanks

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            The pictures that it "doesn't find" the correct caption. Does that right header tag exist? How big does it claim the value is?

            Comment

            Working...