Firebird 2.5 - load and save images to blob field lazarus / 16-Databases ---------------------------------------------------------------------- rc.1990 · 2016-09-27 16:06 I am using Lazarus 1.6, FPC 3.0.0 and Firebird 2.5. How can I load and save images to Firebird 2.5 blob field using TIBConnection, TSQLTransaction, TSQLQuery and a TImage component? ---------------------------------------------------------------------- molly · 2016-09-27 16:14 Perhaps this can work for you as a start for reading blob-fields (the write would be similar but the other way around) ? Keep in mind though, i'm not into databases so also can't help you out with those parts. ---------------------------------------------------------------------- rc.1990 · 2016-09-27 20:34 Thanks molly. I am trying to port a function, without success, that works on Delphi. I have changed the Delphi unit JPeg to Lazarus unit Graphics, and Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses ...   Graphics,      LCLType, // HBitmap type     IntfGraphics, // TLazIntfImage type     fpImage, // TFPColor type     FPReadJpeg, FPWriteJpeg; // jpg support     Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure LoadImageFromField(Image: TImage; ImageField: TBlobField);var  MemStrm:    TMemoryStream;  Jpg:        TJPEGImage;begin    if ImageField.IsNull then    begin      Image.Picture.Assign(nil);      Exit;    end; //if    Jpg := TJPEGImage.Create;    try      MemStrm := TMemoryStream.Create;      try        ImageField.SaveToStream(MemStrm);        MemStrm.Seek(0,soFromBeginning);        with Jpg do begin          PixelFormat := jf24Bit;          Scale := jsFullSize;          Grayscale := False;          Performance := jpBestQuality;          ProgressiveDisplay := True;          ProgressiveEncoding := True;        LoadFromStream(MemStrm);        end; //with        Image.Picture.Assign(Jpg)      finally        MemStrm.Free;      end; //try    finally      Jpg.Free;    end; // fim try finallyend;  But I am still receiving errors on some properties e values: Compile Project, Target: TestImages.exe: Exit code 1, Errors: 7, Hints: 1 BasicRoutines.pas(433,26) Error: Identifier not found "jf24Bit" BasicRoutines.pas(434,11) Error: Identifier not found "Scale" BasicRoutines.pas(435,21) Error: No member is provided to access property BasicRoutines.pas(437,11) Error: Identifier not found "ProgressiveDisplay" BasicRoutines.pas(438,31) Error: No member is provided to access property Can you help find the right units that seems to miss? ---------------------------------------------------------------------- molly · 2016-09-27 20:42 I apologize upfront in case i'm way off here, but can't you simply use Image.Picture.LoadFromStream ? ---------------------------------------------------------------------- Jurassic Pork · 2016-09-27 22:01 hello, rc.1990 have a look to my database example (in Lazarus\examples\Database\Image_Mushrooms ) : Quote[MushRoomsDatabase by Jurassic Pork using SQLite - January 2014 Updated for Firebird Embedded - August 2014 Features: - Use SqlDb and lazreport components. - Sqlite3 or Firebird embedded database DeadlyMushrooms with 5 mushrooms. Sqlite3 will be tried first; if no Sqlite library is available, Firebird embedded will be tried. - It demonstrates: - creating a new SQLite3 database with table if the db does not exist - use of TSQLScript to run multiple SQL statements - use of FBAdmin to restore Firebird backup (smaller than the live .fdb file) on first run, useful for keeping your setup file small and compatible with older Firebird versions - The images are stored in blob field without extension at the beginning. With this you can view blob images with database browser editor (e.g. sqlite2009pro). - In the database there is also a field with images links (filenames). - The linked images are stored in the folder images of the project. - You can see the linked images in a Timage. - You can change the images in the database: - for Tdbimage (image in db): double click on the component and choose your image. - for Timage (linked image): click on the button near the image filename (you must be in edit mode). - Transaction commits when you click on Tdbnavigator refresh button or on close form. - Small pictures of the mushrooms are in the sqlite3Database. Largest images are in files in the folder images. - Print button to print all the mushrooms (lazreport). On each page you have: - a title. - the field common_name of the mushroom database. - the field notes of the mushroom database. - the field picture of the mushroom database (picture picture1). - the picture of the field image_link (picture picture2). The report name is Mushroom_Report.lrf/quote] Friendly, J.P ---------------------------------------------------------------------- LacaK · 2016-09-28 05:10 Quote from: rc.1990 on September 27, 2016, 10:34:39 pmCompile Project, Target: TestImages.exe: Exit code 1, Errors: 7, Hints: 1 BasicRoutines.pas(433,26) Error: Identifier not found "jf24Bit" BasicRoutines.pas(434,11) Error: Identifier not found "Scale" BasicRoutines.pas(435,21) Error: No member is provided to access property BasicRoutines.pas(437,11) Error: Identifier not found "ProgressiveDisplay" BasicRoutines.pas(438,31) Error: No member is provided to access property Can you help find the right units that seems to miss? Lazarus TJPEGImage has not same properties like Delphi's has. Look at: http://lazarus- ccr.sourceforge.net/docs/lcl/graphics/tjpegimage.html Try replace lines or comment lines where you got errors. ---------------------------------------------------------------------- rc.1990 · 2018-08-03 11:46 Thanks all. Solved. Storing .bmp or .jpg file image, to database, use same code? http://forum.lazarus.freepascal.org/index.php?topic=17606.0 Firebird 2.5 - load and save images to blob field http://forum.lazarus.freepascal.org/index.php?topic=34191.0 SQLdb with PostgreSQL blob http://forum.lazarus.freepascal.org/index.php/topic,16205.0.html BLOB and MySQL http://forum.lazarus.freepascal.org/index.php?topic=7890.0 Trouble saving blob to file http://forum.lazarus.freepascal.org/index.php?topic=20648.0 DBImage & Firebird: error in showing image from BLOB field http://forum.lazarus.freepascal.org/index.php?topic=40259.0 Guardar y leer imágenes en bases de datos. https://lazarus-freepascal.blogspot.com.ar/2018/02/guardar-y-leer- imagenes-en-bases-de.html