I'm asking this question out of curiosity. Basically I'm using glide for loading images into imageView by setting the scaleType of image to centerCrop .But what I'm asking is Is it worth or good practice to use the glide's centercrop method instead of imageview's scaletype?.
I'm asking this because as far as I know glide will first download the image and then transform it into required shape .So, I don't think it will increase the downloading speed of image. Then where this method is useful?
Related
I use Glide for image loading. Now I want to set the scaleType of an image to centerCrop.
There are 2 ways of which I know of doing it:
1. By setting the scaleType attribute of the ImageView to centerCrop in the layout
2. By using Glide calling GlideApp.centerCrop()
The optical results of both ways are identical.
Now my Question is: Does it make a considerable difference, which way I choose, maybe regarding performance or quality or else?
We are using Picasso for image handling on our app and we have been having problems with pixelated images. Unfortunately I have been unable to figure out why this is happening, whether by trying out different combinations of things on Picasso, or trying to find the answer online.
Here is our code for image handling currently (some parameter names changed to be easier to read):
Picasso.with(image.getContext())
.load(imageUrl)
.resize(100, 125)
.centerCrop()
.placeholder(R.drawable.image1)
.error(R.drawable.image2)
.transform(new RoundedTransformation(10, 4))
.into(image)
The RoundedTransformation function just gives the images rounded corners and the code for it is here (we did not write this code): https://gist.github.com/aprock/6213395
centerCrop is necessary to prevent the images from being stretched out when they are put into the ImageView.
Does anyone know why pixelation of images might be happening? Thanks and have a great day.
I'm using picasso to load images in my recycler view adaper but it is taking to much time to load image. Here is my call to load image with picasso.
Picasso.with(hostActivity).load("ImageUrl").fit().centerCrop().into(holder.ImageView);
If I do same thing with asynctask task, image loaded instantly.
Am I doing any thing wrong?
Thanks.
fit() needs to wait for the size of the ImageView to be determined before it can size the image to match, and the size can't be calculated until the end of the layout pass. You might get quicker results by using resize() if you are able to predict reasonable width and height values.
You might also want to look at the Glide library as it takes a different approach to caching that can be quicker than Picasso in some cases, for example instead of caching full size images it caches the resized ones. However, there are many pros and cons to both libraries; although the syntaxes are very similar, some things that work in Picasso will not work in Glide, and vice versa.
I am looking for Google Photos app style image manipulation. I am kind of new to image processing. Any leads on how to make the cropping rectangle with the image the same size as cropping rectangle, rotation (which rotates both the image and cropping rectangle), image straightening (including how to get that angle slider kind of UI) will be great. If there are some libraries that has these features, that will also work.
Square has a library for loading and playing with images.
Here are some features:
- Handling ImageView recycling and download cancelation in an adapter.
- Complex image transformations with minimal memory use.
- Automatic memory and disk caching.
There is detailed information on how to use the lib on their website. Check it out: Picasso
The gradle line you need to add is:
compile 'com.squareup.picasso:picasso:2.5.2'
It's very easy to use. Here is how I load and adjust an image into an ImageView in my example app:
Picasso.with(mContext).load("http://cdn0.vox-cdn.com/uploads/chorus_asset/file/798874/DSCF1913.0.jpg").fit().centerCrop().into(imageView);
As you can see, I've used fit().centerCrop() here. This will adjust the image to fit proportionally inside my imageView. You can try different forms of image transformations to better fit your needs.
You can also load images from your drawable folder or directly from file:
Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.with(context).load(new File(...)).into(imageView3);
EDIT:
Looks like I didn't fully understand your question when I first read it. Here are some tips for what you're trying to achieve. May not be exactly what you want, but I think it might be a start.
If you want to rotate your image, you can do it with Picasso using RequestCreator.rotate(float degrees).
Here's the documentation for RequestCreator.
As for cropping images (inside a specified rectangle, as you've shown), there is:
Android crop.
Or you can use Picasso Transformations and create a transformation like
CropTransformation(Top, Center, Bottom);
And ask Picasso to transform the image like this:
Picasso.with(mContext).load(R.drawable.demo)
.transform(transformation).into((ImageView) findViewById(R.id.image));
Also, as #Amit K Saha said on his answer, you can use some Android SDK effects. Check android.media.effect.
Hope this helps.
There are some help from android sdk. May not be exactly what you are looking but worth of a shot to start. Have a look here.
android.media.effect
And list of available effects can be found here
http://developer.android.com/reference/android/media/effect/EffectFactory.html
I've been researching but I've not found anything good. Is there a way to resize images retrieved from a remote resource without the image losing quality? As for now, I do not have anything to resize my images. I just added android:scaleType="fitCenter" within my xml.
Have you tried Picasso? It's a powerful image loader, simple and easy to use. Below code is an example of how to use it.
Picasso.with(context)
.load(url)
.resize(width, height)
.centerCrop()
.into(imageView);
The only way for an image to be resized without losing quality are vectorized images.