0

I'm trying to figure out what the optimal workflow would be for an image transformation process in which a transformed image is again uploaded to another API.

According to Cloudinary (http://cloudinary.com/documentation/image_transformations#resizing_and_cropping_images), I can access uploaded images with the following kind of URL structure and also simultaneously transform them: http://res.cloudinary.com/demo/image/upload/w_200,h_100/sample.jpg.

Assuming that sample.jpg already exists in Cloudinary, the provided link will fetch it with a image resize transformation already applied.

Can I simply provide this link to Picasso and turn it into a Bitmap?

Picasso.with(this)
    .load("http://res.cloudinary.com/demo/image/upload/w_200,h_100/sample.jpg")
    .into(new Target() {
        @Override
        public void onBitmapLoaded (final Bitmap bitmap, Picasso.LoadedFrom from){
            /* Save the bitmap or do something with it here */
            UploadBitmap(bitmap);
        }
});
Martin Erlic
  • 5,467
  • 22
  • 81
  • 153

1 Answers1

1

Sorry, don't really know how to do it with Picasso, but with Glide you can do the following

Glide.with(this).load("path").asBitmap().listener(new RequestListener<String, Bitmap>() {
        @Override
        public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
            return false;
        }

        @Override
        public boolean onResourceReady(Bitmap resource, String model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
            return false;
        }
    }).into(500/*output width*/,500/*output height*/);

And yes, buy specifying w and h in path you can manipulate image scaling

Ekalips
  • 1,473
  • 11
  • 20
  • It's just exit size of `Bitmap`. Perhaps you should place same values into path and there –  Ekalips Jan 20 '17 at 12:19
  • Okay yeah this is what I was looking for. I'll probably stick to Cloudinary for the scaling bit. Just wanted to confirm that I could take the URL and create a bitmap. – Martin Erlic Jan 20 '17 at 12:19