locked
Exif Problem RRS feed

  • Question

  • User-1579609451 posted
    I am having a little problem saving an image with exif data.

    When I try to save an image after resizing it I seem to lose some of the exif infomation associated with it.  It keeps the camera model and the date time but it loses the rest for instace focal length and apature. A simplified version of the code which exibits the problem is below.  If  I set a break point and inspect bitmap b after the foreach loop it has all the property items associated with it, but after the save the file does not have them. Sample image at http://ben-wild.co.uk/img_0671.jpg thanks for any input anyone can offer.
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Collections.Generic;
    using System.Text;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    Bitmap c = new Bitmap(@"C:\IMG_0671.JPG");
    Bitmap b = new Bitmap(c, new Size(100, 200));

    foreach (PropertyItem p in c.PropertyItems)
    {
    b.SetPropertyItem(p);
    }
    c.Save(@"C:\smaller.JPG");
    }
    }
    }
     
    Tuesday, June 20, 2006 11:59 AM

All replies

  • User-1579609451 posted
    From another forum and added for completness

    Easy fix I think: b.Save(@"C:\smaller.JPG", ImageFormat.Jpeg).  Without specifying the format, the image is saved in the PNG format.  I double-checked if the focal length property was copied.  The smaller.jpg file did indeed contain property ID 37386.
    Wednesday, June 21, 2006 4:14 AM