+1

Difference among Picasso, UIL, Glide & Fresco

In the modern Android applications, there is a top requirement to load images from the specified urls. In that case, no matter what type or size of image data needs to be loaded inside the app, but it's matter to manage the image size, caching as well as handling other possible exceptions.

In this case, luckily there are already few well-known libraries are existing, for example:

1. Picasso

Url http://square.github.io/picasso

Download via Gradle

 compile 'com.squareup.picasso:picasso:2.5.2'

Sample usage

Picasso.with(context)
  .load(url)
  .resize(50, 50)
  .centerCrop()
  .into(imageView)

2. Universal Image Loader (UIL)

Url https://github.com/nostra13/Android-Universal-Image-Loader

Download jar

 https://github.com/nostra13/Android-Universal-Image-Loader/raw/master/downloads/universal-image-loader-1.9.5.jar

Sample usage

//  Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view 
//	which implements ImageAware interface)
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(imageUri, imageView);

// Load image, decode it to Bitmap and return Bitmap to callback
imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() {
	@Override
	public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
		// Do whatever you want with Bitmap
	}
});

// Load image, decode it to Bitmap and return Bitmap synchronously
Bitmap bmp = imageLoader.loadImageSync(imageUri);

3. Glide

Url https://github.com/bumptech/glide

Download via Gradle

  repositories  {
        mavenCentral() 
  }
 compile 'com.github.bumptech.glide:glide:4.0.0'

Sample usage

Glide
    .with(myFragment)
    .load(url
    .centerCrop()
    .placeholder(R.drawable.loading_spinner)
    .crossFade()
    .into(myImageView);

4. Fresco

Url https://github.com/facebook/fresco

Download via Gradle

compile 'com.facebook.fresco:fresco:1.2.0'

Sample usage

Fresco.initialize(context);
<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/sdvImage"
    android:layout_width="130dp"
    android:layout_height="130dp"
    fresco:placeholderImage="@drawable/myPlaceholderImage" 
    fresco:failureImage="@drawable/error"
    fresco:failureImageScaleType="centerInside"
    fresco:retryImage="@drawable/retrying"
    fresco:retryImageScaleType="centerCrop"
    fresco:progressBarImage="@drawable/progress_bar"
    fresco:progressBarImageScaleType="centerInside"
    fresco:progressBarAutoRotateInterval="1000"/>
Uri imageUri = Uri.parse("https://i.imgur.com/tGbaZCY.jpg");
SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.sdvImage);
draweeView.setImageURI(imageUri);

The above 04 libraries are well recommended, but still there are few basic differences among these 04 libraries are shown below:-

chart

Now, it's your choice 😄 Happy coding!


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí