Picasso — Additional Transformations with Transformation Library

We're back with another Picasso transformation post. We've already shown you how to transform images in a previous post. There are a few implementations for Picasso transformations floating around on the Internet, but it's tedious work to find a good one for your need. In this blog post, we'll show you how to integrate and use a collection of transformations.

In case you want to catch up with previous Picasso topics, check out our extensive list of blog posts:

Picasso Series Overview

Picasso Transformation Library

If you already have an idea what kind of transformation you might be able to use in your app, take a second to look at the following library: picasso-transformations. It provides a whole collection of various Picasso transformations. It's worth to check if your idea might already be implemented.

The library ships with two different versions. The extended version includes more transformations, which are computed on the device's GPU. They require an additional dependency, so the setup for the two versions is a little bit different. You should look through the list of transformations and decide which version you need.

Setup for Picasso Transformations

The setup is easy! For the basic version you can just add another line to your current build.gradle:

dependencies {  
    compile 'jp.wasabeef:picasso-transformations:2.1.0'
}

If you would like to use the GPU transformations:

repositories {  
    jcenter()
    mavenCentral()
}

dependencies {  
    compile 'jp.wasabeef:picasso-transformations:2.1.0'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
}

Usage of Picasso Transformations

After you've synced Android Studio with the build.gradle file, you can go ahead and use the transformation collection. The usage pattern is the same as with your own, custom transformations. Let's assume we would like to crop an image to a circle with the collection's transformation:

Picasso  
    .with(context)
    .load(UsageExampleListViewAdapter.eatFoodyImages[0])
    .transform(new CropCircleTransformation())
    .into(imageViewTransformationBlur);

You can also apply a list of transformations by chaining the transform() calls.

int color = Color.parseColor("#339b59b6");

Picasso  
        .with(context)
        .load(UsageExampleListView.eatFoodyImages[0])
        .transform(new ColorFilterTransformation(color))
        .transform(new CropCircleTransformation())
        .into(imageViewTransformationLibrary);

Outlook

In this blog post, you've seen how to integrate the Picasso transformation library. A ton of transformations are already implemented and the library gives you a fast and easy access to them. Make sure you check it out!

If you’ve questions or ideas on how to improve this post, leave them in the comments below or shout out @futurestud_io on Twitter.

Make it rock & enjoy coding!


Explore the Library

Find interesting tutorials and solutions for your problems.