3

Can some one help me how to retrieve the file path where the image is stored using glide in cache? I want to send the image loaded with glide into image view to server. May I know how I can get the file path of cached image? The reasons for choosing the glide cached image is its much smaller in size to upload to server.

If it's not possible can someone suggest the way to compress the image?

I have tried different image compression algorithms but none is giving as best as glide.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
user3044690
  • 46
  • 1
  • 4

1 Answers1

3

Glide supports SimpleTarget that gives Bitmap when loading is complete .

 private SimpleTarget target = new SimpleTarget<Bitmap>() {  
    @Override
    public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {

        // upload bitmap here after saving it to your disk

    }
  };

Then use the target as

Glide
    .with( context ) // could be an issue!
    .load( eatFoodyImages[0] )
    .asBitmap()
    .into( target );

More learning at https://futurestud.io/tutorials/glide-callbacks-simpletarget-and-viewtarget-for-custom-view-classes

Gufran Khurshid
  • 888
  • 2
  • 9
  • 28
  • Why is animation parameter there? Bitmap holds single frame. If gif is animated then Bitmap will be null or what? – CrackerKSR Mar 13 '22 at 05:42