How to get image description title in C #?

I have a file with the following properties:

Coral image properties

I want to get the name of the description "Dragon Eye Coral". How can I do it?

I tried to do this with the following code, but without any results:

public string GetImageTitle(Image img) { const int metTitle = 0x0320; var props = img.PropertyItems; var Title = props.FirstOrDefault(x => x.Id == metTitle); if (Title != null) { var myObject = Encoding.ASCII; var PicTitle = myObject.GetString(Title.Value, 0, Title.Len - 1); return PicTitle; } return ""; } 
+6
source share
1 answer

I tried the code below and its performance .. You just need to change the metTitle int value

  Image im = Image.FromFile("image file path"); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); var allPoprItem = im.PropertyItems; const int metTitle = 0x10e; var Title = allPoprItem.FirstOrDefault(x => x.Id == metTitle); Console.WriteLine(encoding.GetString(Title.Value)); 

I can get any header that I set for the image. Try it.

0
source

All Articles