ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving Thumbnails and EXIF Data in a Database

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
JimMellish Posted - Jun 01 2017 : 10:06:33
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
2   L A T E S T    R E P L I E S    (Newest First)
JimMellish Posted - Jun 02 2017 : 11:08:39
Hi Nigel,

Thanks for the reply. I didn't use TIEDBBitmap because ... I didn't know it was there. Everything is now working well.

Jim
xequte Posted - Jun 01 2017 : 16:51:25
Hi Jim

There are a few issues here:

1. You call ParamsFromFile after LoadFromFile. ParamsFromFile is the same as LoadFromFile but skips the image loading, so you don't need it.

2. You need to be aware of your Params object (the class that stores all of the EXIF and other meta-data). In your code below you are using the ImageEnIO.Params. You can optionally use the IEBmp.Params if you call IEBmp.ParamsEnabled := True.

3. Why not use the TIEDBBitmap class? It is a TIEBitmap with DB support:

https://www.imageen.com/help/TIEDBBitmap.html


In the code below, you don't need the ImageEnIO because TIEBitmap supports stream saving anyway (though it doesn't hurt).

Here's an example:

// Append a thumbnail to the database (with its meta-data)
MyBMP := TIEDBBitmap.Create();
MyBMP.ParamsEnabled := True; // So bitmap stores the params
MyBMP.Read( 'D:\MyBlobImage.jpeg' );
IEBmp.Resample (100, 100, rfFastLinear, True); // Convert to thumbnail
MyTable.Append;
MyTableName.AsString := 'My Thumbnail';
MyBmp.Write( MyTableImageBlob, ioJPEG );
MyTable.Post;
MyBmp.Free;




Nigel
Xequte Software
www.xequte.com
nigel@xequte.com