Local image caching solution for Android: Square Picasso vs Universal Image Loader

Local image caching solution for Android: Square Picasso vs Universal Image Loader

http://stackoverflow.com/questions/19995007/local-image-caching-solution-for-android-square-picasso-vs-universal-image-load图片缓存库使用对比

question

I need async image loading and caching in Android. Anyone knows about these two libraries? I was going to use Picasso, but I found Universal Image Loader is more popular on Github. A summary of pros and cons would be great.(All my images are on disk locally,
so I don‘t need networking, I don‘t think Volley is a fit)

Answers

If you read this post on G+ by Koush you will get clear solutions for your confusions, I have put the summary of that, in that Android-Universal-Image-Loader is the winner for your requirement!

  • Picasso has the nicest image API if you are using network!
  • UrlImageViewHelper +
    AndroidAsync is the fastest. Playing with these other two great libraries have really highlighted that the image API is quite dated, however.
  • Volley is slick; I really enjoy their pluggable backend transports,and may end up dropping AndroidAsync in there. The request priorityand cancellation management is great(if you are
    using network)
  • Android-Universal-Image-Loader is the most popular one out therecurrently. Highly customizable.

This project aims to provide a reusable instrument for asynchronous image loading, caching and displaying. It is originally based on Fedor Vlasov‘s project and has been vastly refactored and improved since then.

Upcoming changes in new UIL version (1.9.2):

Possibility to call ImageLoader out of UI threadNew Disk Cache API (more flexible). New LruDiscCache based on Jake Wharton‘s DiskLruCache.

Considering all this Android-Universal-Image-Loader suites your requirement (Loading the images are on disk locally)!

----------

Koushik Dutta‘s comparison is mostly for speed benchmark. His post only touched very basic things, and is not specific for local images. I‘d like to share my experiences with Picasso and UIL after I asked the question. Both Picasso and UIL can load local
images. I first tried Picasso and was happy, but later I decided to switch to UIL for more customization options.

Picasso:

  • Picasso‘s fluent interface is nice. But jumping around with "with", "into", "load" you actually don‘t know what‘s behind the scene. It‘s confusing what‘s returned.
  • Picasso allows you to specify exact target size. It‘s useful when you have memory pressure or performance issues, you can trade off some image quality for speed.
  • Images are cached with size in its key, it‘s useful when you display images with different sizes.
  • You can customize the memory cache size. But its disc cache is only for http requests. For local images, if you care about loading speed, it‘s good to have a thumbnail disk cache so you don‘t have to read several MBs for an image every time. Picasso does
    not have this mechanism resizing and saving thumbnails on disk.
  • Picasso does not expose the access to its cache instance. (You can get a hold of it when you first configure Picasso and keep it around...).
  • Sometimes you want to asynchronously read image into a bitmap returned by a listener. Surprisingly Picasso doesn‘t have that. "fetch()" dose not pass back anything. "get()" is for synchronously read, and "load()" is for asynchronously draw a view.
  • Picasso only has a few simple examples on the homepage, and you‘ll have to read through the unordered javadoc for advanced usages.

UIL:

  • UIL uses builders for customization. Almost everything can be configured.
  • UIL does not allow you to specify the size you want to load into a view. It uses some rules based on the size of the view. It‘s not as flexible as Picasso. I have no way to load a lower resolution image to reduce memory footprint. (Edit: this behavior can
    be easily modified by adding an ImageSize argument in in the source code and bypass the view size checking)
  • UIL provides customizable disc cache, you can use this to cache the thumbnails with specified size. But it‘s not perfect. Here are the
    details. (Edit: if you care about speed and want multiple levels of thumbnail caching, like my case, you can modify the source code, let the disk cache use "memoryKey", and make it also size sensitive)
  • UIL by default caches images of different sizes in memory, and it can be turned off in configuration.
  • UIL exposes the backing memory and disk cache you can access.
  • UIL provides flexible ways you can get a bitmap or load to a view.
  • UIL is better in documentation. UIL gives the detailed usages on the Github page, and there‘s a linked tutorial.

I suggest starting with Picasso, if you need more control and customization, go for UIL.

时间: 2024-07-31 16:19:40

Local image caching solution for Android: Square Picasso vs Universal Image Loader的相关文章

【Android应用开发】 Universal Image Loader ( 使用简介 | 示例代码解析 )

作者 : 韩曙亮 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/50824912 相关地址介绍 : -- Universal Image Loader 项目 GitHub 官方地址 : https://github.com/nostra13/Android-Universal-Image-Loader . -- Universal Image Loader 项目完整中文注释版, 已经将所有类都进行了中文注释, 适合源码学习参

Android框架Picasso的使用简介

Introduction Images add much-needed context and visual flair to Android applications. Picasso allows for hassle-free image loading in your application-often in one line of code! Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(i

开源项目Universal Image Loader for Android 说明文档 (1) 简介

 When developing applications for Android, one often facesthe problem of displaying some graphical content from the Internet. So, youshould provide image loading from the Web in an Android app, their processingand displaying with limited memory aga

开源项目Universal Image Loader for Android 说明文档 (1) 简单介绍

 When developing applications for Android, one often facesthe problem of displaying some graphical content from the Internet. So, youshould provide image loading from the Web in an Android app, their processingand displaying with limited memory aga

Android中Universal Image Loader开源框架的简单使用

UIL (Universal Image Loader)aims to provide a powerful, flexible and highly customizable instrument for image loading, caching and displaying. It provides a lot of configuration options and good control over the image loading and caching process.(不知道

Android Universal Image Loader 使用

1. 功能介绍 1.1 Android Universal Image Loader Android Universal Image Loader 是一个强大的.可高度定制的图片缓存,本文简称为UIL. 简单的说 UIL 就做了一件事--获取图片并显示在相应的控件上. 1.2 基本使用 1.2.1 初始化 添加完依赖后在Application或Activity中初始化ImageLoader,如下: public class YourApplication extends Application

android - android Couldn't load runtimecore_java from loader

在写Arcgis Android 或百度Android的时候,有时会报诸如,java.lang.UnsatisfiedLinkError:android Couldn't load runtimecore_java from loader 的错误,需要将对应的 sdk下的libs下的armeabi和armeabi-v7a放到Android eclipse中的libs下. android - android Couldn't load runtimecore_java from loader

Android图片异步加载框架Universal Image Loader的源码分析

项目地址:https://github.com/nostra13/android-universal-image-loader 1. 功能介绍 1.1 Android Universal Image Loader Android Universal Image Loader 是一个强大的.可高度定制的图片缓存,本文简称为UIL. 简单的说 UIL 就做了一件事--获取图片并显示在相应的控件上. 1.2 基本使用 1.2.1 初始化 添加完依赖后在Application或Activity中初始化I

Android 使用Universal Image Loader绘制带圆角的图片(一)

Android 使用Universal Image Loader绘制带圆角的图片(一) 绘制带圆角的控件难吗?貌似不难.对于一个普通layout或者widget,要绘制圆角,只要把 background设置成下面这样的drawable就行了. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/and