Skip to content Skip to sidebar Skip to footer

How To Compress Image Using Picasso Library For Android?

My Application captures Image using Camera Intent. The image is saved to a file as 'abc.jpg'. Now using Picasso Library I try to compress the image by resizing it. I dont get any o

Solution 1:

You shouldn't use Target as an anonym class. Define an object for it and pass this reference to the into() function. For example:

Target myTarget = new Target(){...}

and then,

Picasso.with(context) .load(_path).resize(size, size).centerCrop().into(myTarget);  

The reason for this is that an anonym class gives a really weak reference, which means that the Target gets Garbage collected.

Tell me if it worked.


Post a Comment for "How To Compress Image Using Picasso Library For Android?"