Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to get data from the tags of a TIFF image

how to get data from the tags of a TIFF image

Scheduled Pinned Locked Moved C#
helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gilvani
    wrote on last edited by
    #1

    Getting the data from the tags of a TIFF image I'm trying to make a program that opens a TIFF image and puts the data from the tags in texboxs but I do not know how to extract the data. If anyone knows how can help me. thanks :doh:

    L 1 Reply Last reply
    0
    • G gilvani

      Getting the data from the tags of a TIFF image I'm trying to make a program that opens a TIFF image and puts the data from the tags in texboxs but I do not know how to extract the data. If anyone knows how can help me. thanks :doh:

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, here is some code I've been using for that purpose, it was aiming at JPEG though:

      FileStream stream=new FileStream(fileSpec, FileMode.Open, FileAccess.Read);
      //File.OpenRead(fileSpec);
      Image localImage2=Image.FromStream(stream);
      

      #if true
      int[] piList=localImage2.PropertyIdList;
      Dictionary<int, string> propNames=new Dictionary<int,string>();
      propNames.Add(0x010E, "ImageDescription");
      propNames.Add(0x010F, "EquipMake");
      propNames.Add(0x0110, "EquipModel");
      propNames.Add(0x0112, "Orientation");
      propNames.Add(0x011A, "XResolution");
      propNames.Add(0x011B, "YResolution");
      propNames.Add(0x0132, "DateTime");
      propNames.Add(0x0128, "ResolutionUnit");
      propNames.Add(0x0131, "SoftwareUsed");
      propNames.Add(0x0201, "JPEGInterFormat");
      propNames.Add(0x0202, "JPEGInterLength");
      propNames.Add(0x0213, "YCbCrPositioning");
      propNames.Add(0x501B, "ThumbnailData");
      propNames.Add(0x502D, "ThumbnailResolutionX");
      propNames.Add(0x502E, "ThumbnailResolutionY");
      propNames.Add(0x5090, "LuminanceTable");
      propNames.Add(0x5091, "ChrominanceTable");
      propNames.Add(0x829A, "ExifExposureTime");
      propNames.Add(0x9003, "ExifDTOrig");
      propNames.Add(0x9004, "ExifDTDigitized");
      propNames.Add(0x9204, "ExifExposureBias");
      propNames.Add(0x9209, "ExifFlash");
      propNames.Add(0x927C, "ExifMakerNote");
      propNames.Add(0x9286, "ExifUserComment");
      propNames.Add(0xA002, "ExifPixXDim");
      propNames.Add(0xA003, "ExifPixYDim");
      foreach (int ID in piList) {
      //if (propNames[ID]==null) getPropertyItem(localImage2, ID, propNames);
      if (propNames.ContainsKey(ID)) getPropertyItem(localImage2, ID, propNames);
      }
      #endif
      // we now create a copy, so we can close the filestream
      // MSDN says: You must keep the stream open for the lifetime of the Image object.
      // see also the article "PRB: Image File Is Locked When You Set the PictureBox
      // Image Property to a File"
      localImage=new Bitmap(localImage2);
      stream.Close();
      localImage2.Dispose();

      and

      protected void getPropertyItem(Image image, int ID, Dictionary<int, string> propNames) {
      string s=(string)propNames[ID];
      if (s==null) s="";
      s+=new string(' ', 20);
      s=s.Substring(0, 20);
      string name="Prop"+LP_Format.Hex4(ID)+" "+s;
      string type=null;
      try {
      PropertyItem pi=image.GetPropertyItem(ID);
      s="";
      byte[] bb=pi.Value;
      switch ((PropertyTagType)pi.Type) {
      case PropertyTagType.Byte:
      type="(byte)";
      for (int i=0; i<bb.Length; i++) {
      byte us=bb[i];
      s+=" "+us

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups