[Mono-dev] Reading Exif Data with System.Drawing or Gtk#

Sebastien Pouliot sebastien.pouliot at gmail.com
Mon Sep 27 08:16:39 EDT 2010


On Sun, 2010-09-26 at 17:38 +0200, Patrick Kowalzick wrote:
> Dear List,
> 
> I am reading exif-data from jpegs (mainly thumb and orientation) using 
> System.Drawing. Something like:
> 
> string orientation = null;
> using (FileStream fs = new FileStream(path,FileMode.Open))
>     using (Image img = Image.FromStream(fs,true,false))
>        foreach (PropertyItem pi in img.PropertyItems)
>           if (pi.Id == 274)
>           {
>              orientation =
>                 BitConverter.ToInt16(pi.Value,0).ToString();
>                 break;
>           }
> 
> Important here is the third parameter from Image.FromStream 
> (validateImageData), which should supress loading the complete 
> image-file, if you access exif data only.
> 
> This works fine for MS.net, but mono (2.6 on Ubuntu) reads the complete 
> image. See as well:
> 
> http://tinyurl.com/39jymfs
> "# Status: TODO
> # Comment: useEmbeddedColorManagement and validateImageData aren't 
> supported."
> 
> As a result, there are massive performance differences between MS.net 
> and mono :(.
> 
> So I am looking for alternatives to just read exif data from images, if 
> possible without including third party libraries (maybe taglib# with 
> picture support). I am already using GTK#, so this would be the best 
> solution for me.

Well you can consider contributing the missing code to mono :-)

> What I found so far:
> 
> -System.Windows.Media.Imaging.BitmapSource is not yet included in mono, 
> and will not in mono 2.8(?).
> 
> -Gdk.Pixbuf Solution, but just for reading orientation:
>     Gdk.Pixbuf icon = new Gdk.Pixbuf(path);
>     string orientation = icon.GetOption("orientation");
> Same behaviour: needs to load image first, and I do not find any 
> information, which options I could retrieve via "GetOption".
> 
> 
> Does anyone has a pointer for me, where to search for more information, 
> or how to read Exif Data using Gtk?

Mono (well libgdiplus) use libexif. A quick googling returned the
following link:

http://www.koders.com/csharp/fid6E5A26A44CC15C401B9D4B4C11EE862ECB6B1D26.aspx?s=zoom#L113


Sebastien



More information about the Mono-devel-list mailing list