public void SetExif (Exif.ExifData value) { // Console.WriteLine ("before save"); byte [] raw_data = value.Save (); // Console.WriteLine ("saved"); Marker exif = new Marker (ExifSignature.Id, raw_data); // Console.WriteLine ("new"); Replace (ExifSignature, exif); // Console.WriteLine ("replaced"); }
public static void SaveJpeg (Pixbuf pixbuf, string path, int quality, Exif.ExifData exif_data) { Pixbuf temp = null; if (pixbuf.HasAlpha) { temp = Flatten (pixbuf); pixbuf = temp; } // The DCF spec says thumbnails should be 160x120 always Pixbuf thumbnail = ScaleToAspect (pixbuf, 160, 120); byte [] thumb_data = Save (thumbnail, "jpeg", null, null); exif_data.Data = thumb_data; thumbnail.Dispose (); // Most of the things we will set will be in the 0th ifd Exif.ExifContent content = exif_data.GetContents (Exif.Ifd.Zero); // reset the orientation tag the default is top/left content.GetEntry (Exif.Tag.Orientation).Reset (); // set the write time in the datetime tag content.GetEntry (Exif.Tag.DateTime).Reset (); // set the software tag content.GetEntry (Exif.Tag.Software).SetData (FSpot.Defines.PACKAGE + " version " + FSpot.Defines.VERSION); byte [] data = exif_data.Save (); FPixbufJpegMarker [] marker = new FPixbufJpegMarker [0]; bool result = false; unsafe { if (data.Length > 0) { fixed (byte *p = data) { marker = new FPixbufJpegMarker [1]; marker [0].type = 0xe1; // APP1 marker marker [0].data = p; marker [0].length = data.Length; result = f_pixbuf_save_jpeg (pixbuf.Handle, path, quality, marker, marker.Length); } } else result = f_pixbuf_save_jpeg (pixbuf.Handle, path, quality, marker, marker.Length); } if (temp != null) temp.Dispose (); if (result == false) throw new System.Exception ("Error Saving File"); }