I am trying to determine how to write the camera serial number to a jpeg file using C#. I had thought that it would be case of setting an appropriate EXIF header value (and maybe it is), but when I open the image using C# + System.Drawing.Image.FromFile(…), the image.PropertyIdList array does not include an EXIF id which would seem to represent the serial number.
I then opened the file in Windows File Explorer, for the jpeg file, Properties, and Details, I see no value for “Camera Serial Number”.
I then used Windows File Explorer/Properties/Details to set the camera serial number to “hello”. This persists. However, when I load the image using C# again, I see the same list of Ids as before – ie. I don’t have a new one holding my “hello” serial number.
Is there a way, from C# code, that I can read/write the camera serial number ?
My code is very simple…
static void Main(string[] args)
{
using (var image = System.Drawing.Image.FromFile(@"c:tempexample.jpeg"))
{
foreach (var propertyId in image.PropertyIdList)
{
Console.WriteLine($"{propertyId:x}");
/*
10e image description
10f camera make
110 camera model
131 software name
8298 copyright
9003 original date
9004 digitized date
9286 comment
5091 ChrominanceTable
5090 LuminanceTable
*/
}
}
}
(the first 8 of which I wrote to the JPEG file when I saved it)