Load large images from URL using Picasso - android

I load about images from about 30 different URLs into a ListView using Picasso. Some of the images are small, some of them are quite large (>3MB).
When I think of reducing the images using the Picasso method .resize(width, height) I dont know the original ration of the image I downloaded.
How could I possible know the dimensions of the downloaded (original) image in order to set the "new dimensions" or the resized image in the correct/appropriate relation?
Thanks

Related

Display images with proper dimensions before loading using glide and recyclerview

How do I display images in a facebook like feed? So far I've been using match_parent for width and wrap_content or fixed height. This works well but I need to show proper blank space for image feeds while it's getting lazy loaded. Like how do I set the dimensions properly for the image before loading it from the internet.
I think about getting the aspect ratio or the image dimensions itself via the api. Is it the only correct way or is there some other better way to achieve it using glide or any image loading library?
If you are using glide, you can set a place holder image or drawable with the dimensions you need while the real image is being downloaded.
Glide
.with(context)
.load(UsageExampleListViewAdapter.eatFoodyImages[0])
.placeholder(R.mipmap.ic_launcher) // can also be a drawable
.into(imageViewPlaceholder);

Glide taking a long time to load large images from the web into a recyclerview

I'm implementing a RecyclerView with a grid layout where in each grid element there is an ImageView in which Glide should load an image taken from and API.
The API returns images of varying dimensions but mostly lage files, and gives the following information about each image:
width and height
size and format (jpg/png)
original size url
thumbnail size url
The thumbnail is way too low quality to be used.
It allows me to filter for under or above a specific resolution, but if I do that I end up missing on the most interesting images. I want to be able to download a compressed version of any image, can glide do that? Is there a workaround to speed up the loading of such big images?
I tought of allowing better quality of wifi networks but I would like to cover all cases. Thanks.

Glide takes long time before displaying large images

I am trying to load images (around 5mb each) into ImageView's of size 45x45 dp in a RecyclerView. Even though original image is large, doesn't Glide load a smaller version of it because target ImageView is small? So, I expect Glide to load images in just a few seconds with an average internet speed. But, it takes like 20 seconds. What is the problem?
Images are stored in firebase storage.
Glide code :
Glide.with(context).load(firebaseStorageUrl).into(imageView);
Glide needs to load the full image from the internet before it can resize it. So the download takes a long time the first time. Afterwards it can use the small image from the cahe it created if you have caching activated.
In case you don't want to load smaller files, I recommend using a Gif-drawable library for loading large images from Glide into GifDrawable(works as an ImageView).
It can load files more than 100MB very fast. It works with plain JPG, PNG and BMP too. If these are GIFs, it plays without any delay or freeze.
If drawables declared by android:src and/or android:background are GIF files then they will be automatically recognized as GifDrawables and animated. If given drawable is not a GIF then mentioned Views work like plain ImageView and ImageButton.
Glide downloads the image first, and then you have methods to retrieve the image as bitmap to resize and compress the image. However, that won't solve your problem . Possibly there are two solutions for this:
Keep a low sized image in the server.
Use a File downloader library, which helps to download images serially and asynchronously as a queue, which would help to download the file quick. FileDownloader library is a good option for this.
Use Override in Glide for load image faster.

Picasso Not Downloading High Resolution Image

I have 3 URLs on gridview and only 2 of the 3 images load into the ImageView.
I am using Picaso:
Picasso.with(c).load(imageUrl).placeholder(R.drawable.progress_animation).fit().centerCrop().into(ivPicture);
I have also tried to skip caching:
Picasso.with(c).load(imageUrl).placeholder(R.drawable.progress_animation).fit().centerCrop().memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(ivPicture);
Additional Info of image:
Width 2048 / Height 1371 pixels
File size = 224KB
File format is JPG
When I use Picasso's .resize(h w)to a lower the resolution eg: resize (100 100) for testing the image is downloaded but the aspect ration is not kept as some images will have a 9:6 ratio or vice versa 6:9 or a perfect square 5:5 and therefore I do not want to resize any images to a fixed ratio instead I use .fit().centerCrop() which works very well except for this 1 high-res image, Picasso just loads on the placeholder endlessly without any errors, I can understand if the pixels are too many but the file size is quite small in size I don't know why Picasso is struggling to download a +/- 200KB image.
Is there a way for Picasso to compress images over certain pixels perhaps?
Picasso can not process very big images because will receive out of memory .You must to do image transformation inside native code .Not in java

Load a downscaled image with Android-Universal-Image-Loader

I am using Android-Universal-Image-Loader to load an image into an imageView. Is it possible to show a downscaled version of the image i am loading while the original image has not yet loaded?
As suggested here, the way to achieve your goal would be prepare and download two images, one with less size to show as preview while the big one is downloading

Categories

Resources