* Posted by JochenK on CP *
I need create and write the Thumbnail to exif if no Thumbnail is included,
and i'm confused after a few hours...i think i did something wrong, maybe
you can help me.
I did this:
//Reading the source-file and the Thumbnail
ExifLibrary.ExifFile file = ExifLibrary.ExifFile.Read(filename);
ExifLibrary.JPEGFile tFile = file.Thumbnail;
//Check if a Thumbnail is already included. If not: create one and add...
if (tFile == null)
{
//Create a new Bitmap from the source-File and scale it to 160Pixels
(largest side)
Image img = new Bitmap(filename);
img = Tools.PictureTools.Resize((Bitmap)img, 160);
//Save the smaller Bitmap as a jpg
img.Save(@"D:\temp\testexifthumbnail.jpg", ImageFormat.Jpeg);
//assign the jpg to the thumbnail. ...
file.Thumbnail = new
ExifLibrary.JPEGFile(@"D:\temp\testexifthumbnail.jpg");
//...and save the modified source-file
file.Save(filename + ".modified.jpg");
}
At first, everything seemes to work fine: the modified file ist about the
size of the created thumbnail larger. But if i read the modified file
again, no thumbnail can be exctracted.
Original issue reported on code.google.com by oozcitak on 6 Feb 2010 at 10:24
Original issue reported on code.google.com by
oozcitak
on 6 Feb 2010 at 10:24