Picasso - An Android Library for Image caching, loading, resize & transform

Picasso is a library of SQUARE is used to thread and cache images asynchronously from server (Network), local storage (Disk or Memory) with some other cool functionalities like transform and resize of images. Normally, when we are working with images in mobile application, images loading is an pity issue. When application need to load many images at a time like in list-view or spinner, so due to huge load of it application may slow , crash due to not enough memory or scrolling issue than Picasso will help you a lot as well when you need to make a thumbnail of a heavy image.

Usage is very simple, you just needs to follow the steps as

Internet Permission

Use internet permission, when you need to load image from server (network), otherwise no need of it in loading process.
<uses-permission android:name="android.permission.INTERNET" />
Add Dependency

Before implementation, add the latest dependency of Picasso and sync the project.

implementation 'com.squareup.picasso:picasso:2.71828'
Load Image from link - network

Get view id of images and load images using URL. Pass your link (http://i.imgur.com/DvpvklR.png) in "load()" and imageview id variable in "into()".

Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);
Load Image from disk/memory - Resource Loading

In resource loading, you need to pass image path from drawable/mipmap, file path in local disk or File from memory. Note that you dnot need an Internet Permission for it.

Picasso.get().load(R.drawable.landing_screen).into(imageView );
Picasso.get().load("file:///android_asset/DvpvklR.png").into(imageView );
Picasso.get().load(new File(...)).into(imageView );
Load image in Adaptor

There is a critical need of Picasso, when app is loading images in adaptor. Scrolling, memory crash and app performance issue raise with normal loading of images instead of using Picasso.
@Override public void getView(int position, View convertView, ViewGroup parent) {
  ImageView view = (ImageView) convertView;
  if (view == null) {
    view = new ImageView(context);
  }
  String url = getItem(position);
  Picasso.get().load(url).into(view);
}
Transformation & Resize Image - Thumbnails

Transform images for a good placement of image in a view as well reduction of size to load smoothly.
Picasso.get()
  .load(url)
  .resize(50, 50)
  .centerCrop()
  .into(imageView)

Other cool functions

Normally, we need loading images;while images are loading asynchronously, also error images; when image loading error or other mishap occurs.
Picasso.get()
    .load(url)
    .placeholder(R.drawable.user_placeholder)
    .error(R.drawable.user_placeholder_error)
    .into(imageView);

Note that Picasso is a third party library of SQUARE, and working to resolve the issue of 
  1. Image-view recycling and download cancellation in an adaptor
  2. Image transformations with minimal memory use
  3. Network, memory and disk caching

Comments


  1. Excellent article,We provide many many imformation aboutIf you are looking for personalized option and mass compatibility in your mobile app then android App is the one for you. Android app platform has something everything for everyone and allows unprecedented personalization options. Android is the leading OS in the market covering 90% of the market share. It is supported to other platforms and flexible.
    More info you can vist Android App development
    Thanks for sharing such beautiful information with us

    ReplyDelete
  2. This is a great blog but if you are looking for the best mobile app development company in India (Android, iPhone & iPad). Here is the list of top Indian App Development Companies in 2020.

    ReplyDelete
  3. you want to need Background Remover App? so install app and remove the background of photos.

    ReplyDelete
  4. Check out web developers in India's top 5 website development best practices to guarantee satisfied site visitors!

    ReplyDelete
  5. In this post having more useful information and improve our knowledge.Can you share more valuable information present Technology.

    If you want to make a perfect website or application you can touch with our Android App Development Company in Kuwait or Top Mobile App Development Company now!

    ReplyDelete
  6. Such a useful information.thank you for sharing.
    Visit BookMyConference.A unique, one of its kind Digital Platform made exclusively for peoples and event organizers, that makes booking expo in Pune, conferences in India easy and fast.

    ReplyDelete

Post a Comment