1

I need to load some images from URI to Bitmap variables and perform some operation with them togheter. I need the bitmaps to be squared images with fixes size, scaled down and cropped. By now I use this code:

return Picasso.with(c).load(imageUri).resize(size, size).get();

but, obviously, the image will be resized without keep its aspect ratio.

I want to resize the image with these requirements:

  • the smaller dimension (width or height) should be equals to size
  • the greater dimension should be cropped to size, keep image centered
Noisemaker
  • 181
  • 7
  • refer https://stackoverflow.com/questions/21889735/resize-image-to-full-width-and-variable-height-with-picasso – sasikumar Jul 28 '17 at 11:40

2 Answers2

2

The key is using centerInside after resize. See link

Picasso.with(c).load(imageUri).resize(size, size).centerInside().get()
Fatih Santalu
  • 4,641
  • 2
  • 17
  • 34
0

set your imageview height and width fix inside xml and then set image to imageview like

 Picasso.with(YourActivityName.this)
                        .load(imageUri)
                        .into(imageview_id);
Mahesh Gawhane
  • 348
  • 3
  • 20