How to save jpg image

Forum related to version 6.1.5 of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

iarthur.ora
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 27.09.2005, 07:08

How to save jpg image

Postby iarthur.ora » 27.09.2005, 08:10

Part 1: Insert Image to Blob Field Database,
Use Mysql 4.0.26 +zeoslib 6.15

----------
[syntax="delphi"]with dmdbConnPool.q2 do begin
SQL.clear;
SQL.Add('update employee set PHOTO=:iPic');
SQL.Add('where employeeid=:iEmp');
ParamByName('iEmp').AsString:=dbEmployeeID.text;

if Uppercase(ExtractFileExt(DBEdit14.Text))='.JPG' then begin
Picture:=TPicture.Create;
Picture.LoadFromFile(DBEDIT14.text);
Stream:=TMemoryStream.Create;
TJPEGImage(Picture.Graphic).SaveToStream(Stream);
ParamByName('iPic').SetBlobData(Stream.Memory,Stream.Size);
ExecSQL;

end
else if Uppercase(ExtractFileExt(DBEdit14.Text))='.BMP' then begin
JPG.Assign(Image1.Picture.Graphic);
JPG.CompressionQuality:=70;
JPG.SaveToStream(Stream);
ParamByName('iPic').SetBlobData(Stream.Memory,Stream.Size);
ExecSQL;
Showmessage('BITMAP are saved success : '+DBEdit14.Text);
end;
end;
end; // end of the If Course
Except
on E : Exception do begin
ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
ShowMessage('NOT SUCCESS TO UPLOAD IMAGE');
 Exit;
end; // end of the Exception

end;
finally
JPG.Free;
Stream.Free;
end; // end of the finally try ( First Try )[/syntax]

==========


Part 2: query afterscroll method, to view image

[syntax="delphi"]with dmdbConnPool.q3 do begin
SQL.clear;
SQL.Add('select * from employee ');
SQL.Add('where Employeeid=:Employeeid');
ParamByName('Employeeid').AsString := EmpAdmin.dbEmployeeID.text;
ExecSQL;
open;

if not FieldByName('photo').IsNull then
try
MS:=TStringStream.Create('');
TBlobField(FieldByName('PHOTO')).SaveToStream(MS);
MS.Position:=0;
jpeg:=TJPEGImage.Create;
jpeg.LoadFromStream(MS);
EmpAdmin.Image1.Picture.Bitmap.Assign(jpeg);
finally
jpeg.Free;
ms.Free;
end // end of the try block
else begin
EmpAdmin.image1.Picture :=nil;
end // end of the begin
end[/syntax]

==========
If i use blobstream to save image to mysql, I don't know how to programming. If possible give me a hint, Why I save jpg while get
half of image, but bitmap now problem. I useing BLOB filed in my database. I think I part 1 have problem during save jpg, any change I can fix the jpg problem.

Thank you very much and.

[edit="Michael"]I put your code into syntax-tags - looks better now :wink:[/edit]

User avatar
fduenas
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Postby fduenas » 29.09.2005, 12:29

Plz try to use 6.5.1 version, there are now daily updates. 6.1.5 is not being updated since along time ago. I think this bug is already corrected.

username
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 12.10.2005, 15:00
Location: Bolivia
Contact:

Insert Image to Blob Field Database

Postby username » 21.10.2005, 21:21

Saludos iarthur.ora,

Por qué no intentas cambiar el tipo de campo de Blob a MediumBlob o LongBlob, sucede a veces que la imagen ocupa mucho espacio y solo estos últimos pueden almacenar.

Regards from Bolivia

dungabruxo
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 19.05.2009, 13:58
Contact:

erro after post image

Postby dungabruxo » 08.10.2009, 13:49

I use Delphi 2010 to save a JPG image into a field LONGBLOB, but after saving in a Mysql the Image is saved only BINARY. When I retrieve the image with "SELECT" error occurs "JPG ERROR # 53". Does anyone know why?
P.S. In Delphi 2006 it worked correctly.

Rodrigo Andrade de Oliveira

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 09.10.2009, 21:16

Have a look at the changes in SVN rev. 712 (http://fisheye2.atlassian.com/changelog/zeos/?cs=712)
This patch may solve your problems. It solved all the test suite's problems with delphi 2009+mysql.

Mark
Image


Return to “6.1.5”

Who is online

Users browsing this forum: No registered users and 1 guest