Time to compress

Alexander Stolte

Expert
Licensed User
Longtime User
I am recently changed to Firebase Storage and since I think of the pictures even smaller to compress. My average is 200kb - 300kb, but this is me too large, I want to come under 100 kb, the download times are still too high for me (telecom is to blame). I opened my eyes a bit and came across a library.

the library promises high compressions at no loss.
what do you think about it, is it worth it?
 

DonManfred

Expert
Licensed User
Longtime User

Attachments

  • CompressorV1.0.zip
    7.7 KB · Views: 576

sorex

Expert
Licensed User
Longtime User
the library promises high compressions at no loss.

if you look at the example picture you can already see difference especially on the water without the need to zoom in.

I think it's applying fades or blurs on small grids.
 

James Chamblin

Active Member
Licensed User
Longtime User
the library promises high compressions at no loss.
The library doesn't promise that at all.
Compressor will allow you to compress large photos into smaller sized photos with very less or negligible loss in quality of the image.
Whether it will be better than jpeg or not, I don't know, but I would not use it to compress something that is already jpeg or some other lossy format as it would degrade twice. Using it on png, gif, or some other lossless format might be okay for photographs, but not for games and such.
 

DonManfred

Expert
Licensed User
Longtime User
I can not specify any "Destination Directory Path" he always says "write only".
It is a tooltip?
The property inside the lib is WRITE ONLY, yes. So there is only a setter but no getter.

It is working for me

donmanfredorg1.png is the original

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim comp As Compressor
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    comp.Initialize("Compressor")
    Dim bmp As Bitmap = comp.compressToBitmap(File.DirRootExternal,"donmanfredorg.png")
    comp.DestinationDirectoryPath = File.Combine(File.DirRootExternal,"Compressor")
    comp.compressToFile(File.DirRootExternal,"donmanfredorg.png")
 
    Dim d As BitmapDrawable
    d.Initialize(bmp)
    Activity.Background = d
 
End Sub

compressor001.png


File is successfully created on the internal sdcard in folder Compressor
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
My Source File was a png file the size is 224KB, after compress, this file have a size from 27KB! And I hardly see any difference.

Good Job Don, I'll give you a coffee! With cream.
 
Top