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

  • Hardware for Setting up WebPageTest Agent Devices
  • Setting up an Android phone as a WebPageTest agent
  • AI Awesomeness: 2020 Update! Microsoft Cognitive Services Speaker Recognition API
  • Customized WebPageTest Lighthouse Results using a Custom Test Agent
  • Automating WebPageTest using the nodejs webpagetest-api package
  • Automating WebPageTest via the WebPageTest API

Search

Archives

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