Library to handle asynchronous image loading on Android.
Fetching latest commit…
Cannot retrieve the latest commit at this time.


WebImageLoader is a library designed to take to hassle out of handling images on the web. It has the following features:

  • Images are downloaded on a background thread pool and saved to disk and memory.
  • Disk and memory cache size is configurable and can even be reconfigured on the fly.
  • Separate thread do load images back from disk after being cached, reducing I/O bottlenecks on most phones.
  • Reusing requests when the same image is requested multiple times.
  • Respects cache-control and expires headers and will refetch images when they expire (using conditional get).
  • Support image transformations which are also cached to disk and memory.
  • Support to do synchronous fetches while still taking advantage of the cache.
  • Support for download progress callbacks.
  • Easy setup without singletons.
  • Compatible with API level 7 and up.
  • Only depends on DiskLruCache.


Use the builder to build an ImageLoader that suits your needs.

// Get memory class of this device, exceeding this amount will throw an
// OutOfMemory exception.
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
int memClass = am.getMemoryClass();

// Use part of the available memory for memory cache.
final int memoryCacheSize = 1024 * 1024 * memClass / 8;

File cacheDir = new File(getExternalCacheDir(), "images");
ImageLoader imageLoader = new ImageLoader.Builder(context)
        .enableDiskCache(cacheDir, 10 * 1024 * 1024)

Or use the provided Applications class for convenience and reasonable defaults (which you can override!)

<application android:name="com.webimageloader.ext.ImageLoaderApplication">
    <!-- Your app -->

Retrive your loader like this.

ImageLoader imageLoader = ImageLoaderApplication.getLoader(context);

Loading images

Loading images is simple if you want it to be.

// This will show a nice fade in when the image has loaded
new ImageHelper(context, imageLoader)
        .load(imageView, "");

You can also use specify a loading and failure image

new ImageHelper(context, imageLoader)
        .load(imageView, "");

Loading images can also be done more explicit if needed.

Bitmap b = loader.load(imageView, "", new Listener<ImageView>() {
    public void onSuccess(ImageView v, Bitmap b) {
        // Everything went well

    public void onError(ImageView v, Throwable t) {
        // Something went wrong
        Log.d("MyApp", "Failed to load image", t);

// Did we get an image immediately?
if (b != null) {


You can transform (and cache!) the images you get.

final int width = 100;
final int height = 100;

Transformation t = new SimpleTransformation() {
    public String getIdentifier() {
        // Pass a unique identifier for caching
        return "scale-" + width + "x" + height;

    public Bitmap transform(Bitmap b) {
        return Bitmap.createScaledBitmap(b, width, height, true);

new ImageHelper(this, imageLoader)
        .load(imageView, "", t);


Progress is easy if you have a ProgressBar, it will only be shown when when needed.

// Automatically update the progress bar
new ImageHelper(context, imageLoader)
        .load(imageView, progressBar, "");

Or handle progress yourself.

Bitmap b = loader.load(imageView, "", new Listener<ImageView>() {
    public void onSuccess(ImageView v, Bitmap b) {
        // Same as above

    public void onError(ImageView v, Throwable t) {
        // Same as above
}, new ProgressListener() {
    public void onProgress(float value) {
        // value is in the range 0f-1f


You can include the library by downloading the .jar and also adding DiskLruCache to your project.

If you are a Maven user, simply add the following to your pom.xml:


Developed By


WebImageLoader is licensed under Apache 2.0. If you find this library useful feel free to send me a tweet (or not).

Copyright 2012 Alexander Blom

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.