0

I'm using Fresco library by Facebook to load and show image from URL.

Uri uri = Uri.parse(image_url);
imageView.setImageURI(uri);

How can I resize this image in java?

Ronn
  • 183
  • 2
  • 13

1 Answers1

0

reading the Fresco Documentation, I've found this:

Resizing

Resizing does not modify the original file. Resizing just resizes an encoded image in memory, prior to being decoded.

To resize pass a ResizeOptions object when constructing an ImageRequest:

Uri uri = "file:///mnt/sdcard/MyApp/myfile.jpg";
int width = 50, height = 50;
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
    .setResizeOptions(new ResizeOptions(width, height))
    .build();
PipelineDraweeController controller = Fresco.newDraweeControllerBuilder()
    .setOldController(mDraweeView.getController())
    .setImageRequest(request)
    .build();
mSimpleDraweeView.setController(controller);

Resizing has some limitations:

  • it only supports JPEG files
  • the actual resize is carried out to the nearest 1/8 of the original size
  • it cannot make your image bigger, only smaller (not a real limitation though)

If you have any question, please free to ask

Hope it help

piotrek1543
  • 19,130
  • 7
  • 81
  • 94