Robin Osborne

Web Perf Nerd, lover of making things speedy

Facebook LinkedIn Twitter

Menu

Skip to content
  • Home
  • About

Tag Archives: exif

Is that image a photo?

A very quick hack to check if an image is a photo in C#, using image properties, is to see if there’s a “camera manufacturer” property set:

foreach (var img in Directory.GetFiles(imagedump))
{
    using (var fs = new FileStream(img, FileMode.Open))
    using (var i = Image.FromStream(fs))
    {
        foreach (var p in 
            from p in i.PropertyItems
            where p.Id == 271 // manufacturer property
            select p)
        {
            var encoding = new ASCIIEncoding();
            var manufacturer = encoding.GetString(p.Value);
            Console.WriteLine("Camera make:{0}", manufacturer);
        }
    }
}

Learned from a little msdn article; the value 271 is the integer version of the hex “0x010F” in the table of common IDs.

July 22, 2015Robin Osborne C#, exif, images, metadata, photos 1 Comment

Latest Posts

  • Automate Your WebPageTest Private Instance With Terraform: 2021 Edition
  • Google’s Chrome User Experience Data in WebPageTest
  • WebPageTest Private Instance: 2021 Edition
  • Creating a 4G router using a Raspberry Pi and a mobile phone
  • Hardware for Setting up WebPageTest Agent Devices
  • Setting up an Android phone as a WebPageTest agent

Search

Archives

Proudly powered by WordPress ~ Theme: Syntax by WordPress.com.