iOS Question Compress image not working

falbertini

Member
Licensed User
Longtime User
Hello,
in my app I need to compress captured photo..
I tried using this routine (on my Iphone 4S), but the size is the same and the saved file is not a jpg. It seems like this routine is not working:
B4X:
Dim out As OutputStream = File.OpenOutput(Dir, Filename, False)
Image.WriteToStream(out, 70, "JPEG")
out.Close

How can I reduce the size of an image in B4i?
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I tested it with this code (and a different image):
B4X:
Dim origBitmap As Bitmap = LoadBitmap(File.DirAssets, "IMG_0995.JPG")
Log(File.Size(File.DirAssets, "IMG_0995.JPG"))
Dim out As OutputStream = File.OpenOutput(File.DirTemp, "1.jpg", False)
origBitmap.WriteToStream(out, 20, "JPEG")
out.Close
Log(File.Size(File.DirTemp, "1.jpg"))
The image was compressed from 170k to 57k.
 
Upvote 0
Top