locked
Image tags RRS feed

Answers

  • User472117617 posted

    It's an object (the base class for everything) so you can determine how the Tag is used.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 9:09 AM
  • User-925286913 posted

    Use:

    Dim img As System.Drawing.Bitmap = Nothing

    img = Drawing.Image.FromFile(Server.MapPath("~/Image/Image1"))

    Dim ht As Integer = img.Height

    Dim wt As Integer = img.Width

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 9:17 AM
  • User2138853856 posted

    So, I have found the most easy way.

    .NET framework as from 3.0 version has the special classes for Image metadata.

    Thanks a lot for help!

    http://www.tryexcept.com/articles/2007/10/11/reading-image-metadata-with-net.html

     

    class Program
        {
    
            static void readMetadata(string filename)
            {
                BitmapSource img = BitmapFrame.Create(new Uri(filename));
    
                /* Image data */
                double mpixel = (img.PixelHeight * img.PixelWidth)/(double)1000000;
                Console.WriteLine("  Pixelsize {0}x{1} ({2} megapixels)", img.PixelWidth, img.PixelHeight,mpixel);
                Console.WriteLine("  DPI {0}x{1}", img.DpiX, img.DpiY);
    
                /* Image metadata */
                BitmapMetadata meta = (BitmapMetadata)img.Metadata;
                Console.WriteLine("  metadata\n    Type: {0}",meta.GetType());
                Console.WriteLine("  Title: {0}", meta.Title);
                Console.WriteLine("  Subject: {0}", meta.Subject);
                Console.WriteLine("  Comment: {0}", meta.Comment);
                Console.WriteLine("  Date taken: {0}", meta.DateTaken);
                Console.WriteLine("  Camera: {0} {1}",meta.CameraManufacturer,meta.CameraModel);
                Console.WriteLine("  Copyright: {0}", meta.Copyright);
    
                StringBuilder authors = new StringBuilder();
                if (meta.Author != null)
                {
                    foreach (string author in meta.Author)
                    {
                        authors.Append(author + "; ");
                    }
                    Console.WriteLine("  Author(s): {0}", authors.ToString());
                }
    
    
                Console.WriteLine("  Rating: {0}", meta.Rating);
    
                StringBuilder keyWords = new StringBuilder();
                if (meta.Keywords!=null) {
                    foreach (string keyword in meta.Keywords) {
                        keyWords.Append(keyword+"; ");
                    }
                    Console.WriteLine("  Keywords: {0}", keyWords.ToString());
                }
                Console.WriteLine("");
            }
    
    
            static void Main(string[] args)
            {
                Console.WriteLine("Image metadata");
    
                DirectoryInfo di = new DirectoryInfo(@"d:\pictures");
    
                FileInfo[] files = di.GetFiles("*.jpg");
                foreach (FileInfo fi in files)
                {
                    Console.WriteLine(fi.Name);
                    Program.readMetadata(fi.FullName);
                }
    
                Console.ReadLine();
    
            }
        }
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 5, 2009 6:40 AM

All replies

  • User472117617 posted

    It's an object (the base class for everything) so you can determine how the Tag is used.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 9:09 AM
  • User-925286913 posted

    Use:

    Dim img As System.Drawing.Bitmap = Nothing

    img = Drawing.Image.FromFile(Server.MapPath("~/Image/Image1"))

    Dim ht As Integer = img.Height

    Dim wt As Integer = img.Width

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 29, 2009 9:17 AM
  • User2138853856 posted
    I'm sorry, I don't mean this. Any Image file has special property "tags" - this property can be helpful for the search in image gallery. You can see: right click on the file - Details - Tags. Can I set or get this property in the image file by .NET?
    Monday, June 1, 2009 3:13 AM
  • User2138853856 posted

    These tags (keywords) are in the image metadata.

    Wednesday, June 3, 2009 12:12 PM
  • User-925286913 posted

     

    These tags (keywords) are in the image metadata.

    Can you please expalin what do you mean by tags (keywords) in image metadata?

    Are you talking about alt and title tag of Image?

    Wednesday, June 3, 2009 1:51 PM
  • User2138853856 posted

    Keywords - the section of metadata, that can be helpful and useful for search.

    You can see: Right click on image - Properties - Details - Tags (just win vista)

    Also you can see or edit keywords with a special soft, for instance Adobe Bridge.

    So, I have found one method

    http://forums.asp.net/t/1265325.aspx

    but this DSO COM component only for x86 systems =)

    Now I try to use example from microsoft.

    But if you have one more example, post it please.

    Thursday, June 4, 2009 5:05 AM
  • User2138853856 posted

    So, I have found the most easy way.

    .NET framework as from 3.0 version has the special classes for Image metadata.

    Thanks a lot for help!

    http://www.tryexcept.com/articles/2007/10/11/reading-image-metadata-with-net.html

     

    class Program
        {
    
            static void readMetadata(string filename)
            {
                BitmapSource img = BitmapFrame.Create(new Uri(filename));
    
                /* Image data */
                double mpixel = (img.PixelHeight * img.PixelWidth)/(double)1000000;
                Console.WriteLine("  Pixelsize {0}x{1} ({2} megapixels)", img.PixelWidth, img.PixelHeight,mpixel);
                Console.WriteLine("  DPI {0}x{1}", img.DpiX, img.DpiY);
    
                /* Image metadata */
                BitmapMetadata meta = (BitmapMetadata)img.Metadata;
                Console.WriteLine("  metadata\n    Type: {0}",meta.GetType());
                Console.WriteLine("  Title: {0}", meta.Title);
                Console.WriteLine("  Subject: {0}", meta.Subject);
                Console.WriteLine("  Comment: {0}", meta.Comment);
                Console.WriteLine("  Date taken: {0}", meta.DateTaken);
                Console.WriteLine("  Camera: {0} {1}",meta.CameraManufacturer,meta.CameraModel);
                Console.WriteLine("  Copyright: {0}", meta.Copyright);
    
                StringBuilder authors = new StringBuilder();
                if (meta.Author != null)
                {
                    foreach (string author in meta.Author)
                    {
                        authors.Append(author + "; ");
                    }
                    Console.WriteLine("  Author(s): {0}", authors.ToString());
                }
    
    
                Console.WriteLine("  Rating: {0}", meta.Rating);
    
                StringBuilder keyWords = new StringBuilder();
                if (meta.Keywords!=null) {
                    foreach (string keyword in meta.Keywords) {
                        keyWords.Append(keyword+"; ");
                    }
                    Console.WriteLine("  Keywords: {0}", keyWords.ToString());
                }
                Console.WriteLine("");
            }
    
    
            static void Main(string[] args)
            {
                Console.WriteLine("Image metadata");
    
                DirectoryInfo di = new DirectoryInfo(@"d:\pictures");
    
                FileInfo[] files = di.GetFiles("*.jpg");
                foreach (FileInfo fi in files)
                {
                    Console.WriteLine(fi.Name);
                    Program.readMetadata(fi.FullName);
                }
    
                Console.ReadLine();
    
            }
        }
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 5, 2009 6:40 AM