This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Accessing ExifDictionary members in C# using []

mike_w_mason#11327
I am trying to update the EXIF GPS data for a series of jpg images but am getting an error in Visual Studio when trying to access the ExifDictionary using []. My code is copied directly from the sample in the on-line help:

1. using (Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(imageFullPath)) {
2. using (Aurigma.GraphicsMill.Codecs.JpegWriter writer = new Aurigma.GraphicsMill.Codecs.JpegWriter(imageFullPath)) {
3. Aurigma.GraphicsMill.Codecs.ExifDictionary exif = new Aurigma.GraphicsMill.Codecs.ExifDictionary();
4. exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.GpsLatitude] = latitudeAsExifString;
5. writer.Exif = exif;
}
}

I get the following error on line 4:
Error 1 Cannot apply indexing with [] to an expression of type 'Aurigma.GraphicsMill.Codecs.ExifDictionary' C:\Users\Mike Mason\Documents\My Dropbox\Development\KMLMerge\KMLMerge\Form1.cs 42 13 KMLMerge[/size]

and another error on line 5:
Error 2 'Aurigma.GraphicsMill.Codecs.JpegWriter' does not contain a definition for 'Exif' and no extension method 'Exif' accepting a first argument of type 'Aurigma.GraphicsMill.Codecs.JpegWriter' could be found (are you missing a using directive or an assembly reference?) C:\Users\Mike Mason\Documents\My Dropbox\Development\KMLMerge\KMLMerge\Form1.cs 43 15 KMLMerge



I suspect it is my lack of C# experience coming into play here but as the code is pretty much a copy of the on-line help perhaps it is something else.

Any help would be appreciated,

Mike

Using VS2008, and Graphics Mill 5.1




Tamila#11331
Hello Mike,

The following code demonstrates how to use Exif metadata, try to use this method:
using (Aurigma.GraphicsMill.Codecs.JpegReader reader = new Aurigma.GraphicsMill.Codecs.JpegReader("fileName.jpg"))
using (Aurigma.GraphicsMill.Codecs.JpegFrame frame = (Aurigma.GraphicsMill.Codecs.JpegFrame)reader.LoadFrame(0))
using (Aurigma.GraphicsMill.Codecs.JpegWriter writer = new Aurigma.GraphicsMill.Codecs.JpegWriter("newFileName.jpg"))
{
	Aurigma.GraphicsMill.Codecs.ExifDictionary exif = new Aurigma.GraphicsMill.Codecs.ExifDictionary();

	object[] latitude = new object[3];
	latitude[0] = new Aurigma.GraphicsMill.UnsignedRational(1, 2);
	latitude[1] = new Aurigma.GraphicsMill.UnsignedRational(1, 2);
	latitude[2] = new Aurigma.GraphicsMill.UnsignedRational(1, 2);
	exif.SetItemArray(Aurigma.GraphicsMill.Codecs.ExifDictionary.GpsLatitude, latitude);
	exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.GpsLatitudeRef] = "N";

	writer.Exif = exif;
	writer.AddFrame(frame);
}

mike_w_mason#11341
Thanks Tamila for your response. Unfortunately when using your code example I still get an error at the line:

exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.GpsLatitudeRef] = "N";

Error message is:
Error 1 Cannot apply indexing with [] to an expression of type 'Aurigma.GraphicsMill.Codecs.ExifDictionary'

and the line:
writer.Exif = exif;

Gives the following message:
Error 2 'Aurigma.GraphicsMill.Codecs.JpegWriter' does not contain a definition for 'Exif' and no extension method 'Exif' accepting a first argument of type 'Aurigma.GraphicsMill.Codecs.JpegWriter' could be found (are you missing a using directive or an assembly reference?)

I am sure there must be something I am doing wrong but cannot see it,

Thanks

Mike
Tamila#11343
Hello Mike,

It is a very strange behavior. Try to compile sample project (see attachment) on your machine.
Also I recommend you to use the latest version Graphics Mill 5.1.277. You can download it here:
http://aurigma.com/Products/GraphicsMilldotNET/FreeTrial.aspx

If you still have any problems please send us your sample application where we can reproduce your problem, any additional information will be helpful. If you do not want to post your application here you can submit support case