I am trying to implement image compression for my file upload to Firebase Storage. Normal image choosing and upload works perfectly, but i would now like to implement image compression. I came across Zelory compressor and i am trying to implement but i can't seem to use the code correctly.
I am using this within a fragment and when i am trying to load the bitmap into the compressor line its seems to be giving an error on context:
My code before this is taking the ImageUri and converts it to a file path as needed by compressor.
val image_file_path = File(mImageUri.path)
val ctx = activity!!.applicationContext
val tempBitmap = Compressor.compress(ctx, image_file_path)
mImageUri is what i was using when just choosing and uploading as normal to firebase.
I have had a look at many examples of people trying to use this code and i can't to see what i am doing wrong. is it something to do with the fact that i am using it in a fragment? If so i would not mind changing my layout to just upload in the normal layout rather than a fragment.
I initially had the ctx
input as just activity thinking that was the problem but this doesnt take away the error. any help?