473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.Encoding = System.Text.Encoding.UTF8
Dim aprop As PropertyItem
Dim img As Image
img = New Bitmap("c:\blank1.jpg")
s = " "
Try
img = New Bitmap(img1)
''''''start actual process here''''''''
i = 0
j = 0
s = ""
For Each aprop In img.PropertyItems
If aprop.Id.ToString("x") = "10e" Then
s = Trim(encoding.GetString(aprop.Value))
Exit For
End If
Next

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

Return s
''''''end actual process here''''''''''
End Function
Jun 6 '08 #1
5 1389
Plater
7,872 Expert 4TB
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?
Jun 9 '08 #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?
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.
Jun 10 '08 #3
Plater
7,872 Expert 4TB
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?
Jun 10 '08 #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?

In the code which I have pasted, img.propertyitems 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
Jun 12 '08 #5
Plater
7,872 Expert 4TB
The pictures that it "doesn't find" the correct caption. Does that right header tag exist? How big does it claim the value is?
Jun 12 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Wally | last post by:
I would like to have an image with a caption displayed below it. The size of the image will vary. The caption should not extend beyond the width of the image. How can I cause the text of the...
2
by: Chris Leipold | last post by:
Hi, I habe a page with an image with variable width. I need a caption below the image with the same width as the image. See http://www.dietzk.de/test/ - the first example is what I need. This...
2
by: aqualizard | last post by:
I have made and image with a caption using CSS, but I am hoping someone can show me how to do it better. By better I mean less HTML, and hopefully have it work with any sized image where I do not...
6
by: SPG | last post by:
Hi, I wrote a little bit of script that loads an image from a thumbnail when the thumbnail is clicked. It is not very clever, and I have found it only works in IE.. could someone have a look...
1
by: Eric | last post by:
I want to do the following using CSS, and I just can't seem to find the solution: There is some text here that describes some research or something that I'm doing. Part of the results of the...
11
by: Tomek Toczyski | last post by:
What is the best way to attach a caption to an image in xhtml? I can attach a caption to a table by a "<caption>" tag but I would like to do sth similar to an image. How to do it in a natural...
11
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/Demo/photo%20block%20experiments.html I've ended up with what seems like a rather complex structure for what I thought would be a somewhat simple...
7
by: Peter Parker | last post by:
Could someone show me how to limit caption width to image width dynamically (image width is not known in advance) if that's possible? I was thinking of using Javascript to get the image width which...
0
by: numbnutz | last post by:
Hi, I am currently working on an XML Gallery for my girlfriend's brother who is a photographer. I have created a flash front end template and am using an XML database to load the images and...
5
by: Roderik | last post by:
Hi, I guess I am missing something. I tried to put a caption on my photo (on the bottom) but the caption appears to be a bit higher and overshooting the area of the image with a few pix. You...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.