I need to reduce the space occupied by the photo. Ideally, the photo should weigh less than 1.5Mb. For this I use the code:
I have already encountered the problem that if sometimes I reduce the “quality” parameter to less than 50, then large distortions already appear in the photo, so in the condition I used to reduce the quality until the photo weighs more than 1.5Mb and the quality is not equal to 50. But even now I sometimes encounter large photo defects during compression.
Is there a better photo compression algorithm?
B4X:
Dim Out As OutputStream
Dim FileSize=100 As Int
Bitmap = xui.LoadBitmapResize(File.DirInternal,"FileName.jpg",1280dip,1280dip,True)
Do While File.Size(File.DirInternal,"FileName.jpg")>1500000 And FileSize<>50
Out = File.OpenOutput(File.DirInternal,"FileName.jpg",False)
Bitmap.WriteToStream(Out, FileSize, "JPEG")
Out.Close
FileSize=FileSize-10
Loop
Is there a better photo compression algorithm?
Last edited: