Hi,
I need to store thumbnails and some exif data for a list of files in a database. No visual representation of the images is required.
I need a TIEBitmap to create the thumbnail using Resample and I need a TImageEnIO so I can use SaveToStream to save the thumbnail in the database. The only way I could get this to work is shown below.
try
IEBmp := TIEBitmap.Create;
ImageEnIO := TImageEnIO.CreateFromBitmap(IEBmp);
for i := 0 to Length(Vec) - 1 do
begin
ImageEnIO.LoadFromFile(Vec[i]);
IEBmp.Resample (100, 100, rfFastLinear, True);
{ ... Create blob field and write thumbnail to database ... }
ImageEnIO.ParamsFromFile(Vec[i]);
{ ... Write exif data to database ... }
end;
finally
FreeAndNil(ImageEnIO);
FreeAndNil(IEBmp);
end;
I appears that I am reading the image file from disk twice, once to load the image and once to load the exif data. I have been going round in circles using different combinations of TIEBitmap, TImageEnIO and TIOParams to try and reduce the number of disk reads to one but can't get anything to work. Is there a better way of doing this ?
Jim