best way to compress picture

my code

DbPic=New DatabaseRecord
DbPic.IntegerColumn(“cntid”)=Val(TxtOrderNum.Text)
DbPic.Column(“foto”) =PictureToString(droppicture)
f = SpecialFolder.Temporary.Child(“Temp_Image.jpg”)
''f.saveAsJPEG p
droppicture.Save(f,Picture.SaveAsJPEG ,-1)
bs=BinaryStream.Open(f,False)
If bs <> NIL then
imageData = bs.read(bs.length )
bs.close
DbPic.BlobColumn(“foto”) = EncodeHex(imageData)
End if

how I can compress more the picture to a smaller size to store the data on the Postgresql database

Two thoughts:

  1. JPG pictures are already compressed. You probably won’t gain much by compressing them again.
  2. Encoding binary data as hex will double the size of the data, in which case compression will probably be useful. But I don’t see why it needs to hex encoded at all.

If you can, the most efficient storage is to store a path to an actual file in the database, and the jpg left on disc.

EncodeBase64 will be more efficient than EncodeHex
and yes jpg are already compressed you won’t gain any size by compressing it more.

[quote=341387:@Alexis Colon Lugo]my code

DbPic=New DatabaseRecord
DbPic.IntegerColumn(“cntid”)=Val(TxtOrderNum.Text)
DbPic.Column(“foto”) =PictureToString(droppicture)
f = SpecialFolder.Temporary.Child(“Temp_Image.jpg”)
''f.saveAsJPEG p
droppicture.Save(f,Picture.SaveAsJPEG ,-1)
bs=BinaryStream.Open(f,False)
If bs <> NIL then
imageData = bs.read(bs.length )
bs.close
DbPic.BlobColumn(“foto”) = EncodeHex(imageData)
End if

how I can compress more the picture to a smaller size to store the data on the Postgresql database[/quote]

does it matter if its lossy vs lossless ?
lossless - use PNG
lossy - use JPEG

ok
thanks