Code Monkey home page Code Monkey logo

picasso-transformations's Introduction

Picasso Transformations

Android Arsenal License Maven Central

An Android transformation library providing a variety of image transformations for Picasso.

Please feel free to use this.

Are you using Glide or Fresco?

Glide Transformations
Fresco Processors

Demo

Original Image

Transformations

How do I use it?

Step 1

Gradle

repositories {
    mavenCentral()
}

dependencies {
    compile 'jp.wasabeef:picasso-transformations:2.4.0'
    // If you want to use the GPU Filters
    compile 'jp.co.cyberagent.android:gpuimage:2.1.0
}

Step 2

Set Picasso Transform.

Picasso.with(mContext).load(R.drawable.demo)
    .transform(transformation).into((ImageView) findViewById(R.id.image));

Advanced Step 3

You can set a multiple transformations.

Picasso.with(mContext).load(R.drawable.demo)
    .transform(transformation)
    .transform(new CropCircleTransformation())
    .into(holder.image);

Transformations

Crop

CropTransformation, CropCircleTransformation, CropSquareTransformation, RoundedCornersTransformation

Color

ColorFilterTransformation, GrayscaleTransformation

Blur

BlurTransformation

Mask

MaskTransformation

GPU Filter (use GPUImage)

Will require add dependencies for GPUImage.

ToonFilterTransformation, SepiaFilterTransformation, ContrastFilterTransformation InvertFilterTransformation, PixelationFilterTransformation, SketchFilterTransformation SwirlFilterTransformation, BrightnessFilterTransformation, KuwaharaFilterTransformation VignetteFilterTransformation

Applications using Picasso Transformations

Please ping me or send a pull request if you would like to be added here.

Icon Application
Ameba Ownd
QuitNow!

Developed By

Daichi Furiya (Wasabeef) - [email protected]

Follow me on Twitter

Thanks

License

Copyright (C) 2020 Wasabeef

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

picasso-transformations's People

Contributors

alexfu avatar bitdeli-chef avatar kevinpelgrims avatar koral-- avatar mccrajs avatar molexx avatar pushbit avatar rciovati avatar rocboronat avatar veresvit avatar wasabeef avatar yoann217 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picasso-transformations's Issues

RuntimeException: Transformation BlurTransformation(radius=15, sampling=5) crashed with exception

Device:
apiLevel - 15 (4.0.4)
ZTE - model Grand X In

Cannot reproduce on my devices, reported from user device on production app.

Stack trace:

java.lang.RuntimeException: Transformation BlurTransformation(radius=15, sampling=5) crashed with exception.
at com.squareup.picasso.BitmapHunter$3.run(BitmapHunter.java:434)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Method.java:-2)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(NativeStart.java:-2)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=65536; index=65538
at jp.wasabeef.picasso.transformations.internal.FastBlur.blur(FastBlur.java:125)
at jp.wasabeef.picasso.transformations.BlurTransformation.transform(BlurTransformation.java:73)
at com.squareup.picasso.BitmapHunter.applyCustomTransformations(BitmapHunter.java:429)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:238)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)

how to add Blur Effect using Kotlin

I am sorry if this is trivial, but I am a beginner. and currently I am using Kotlin. I want to blur my image after downloading using picasso.

and here is the code I use:

Picasso.get()
           .load(currentEvent.posterDownloadPath)
           .transform(BlurTransformation(25,3))
           .into(recommendedEventViewHolder.blurryImageView)

but unfortunately I have error like in this image: https://i.stack.imgur.com/Nvq53.png

so how to properly use BlurTransformation effect ?

unable to add from jcenter in android studio 1.3.2

Couldn't get this library from jcenter

Anything I missed here?

image

buildscript {
repositories {

    mavenCentral()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
}

}

repositories {
mavenCentral()

// for using SNAPSHOT
//maven {
//    url uri('https://oss.sonatype.org/content/repositories/snapshots/')
//}

}

apply plugin: 'com.android.application'

dependencies {
compile project(':library')
// Or, fetch from Maven:
// compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.jsoup:jsoup:1.8.2'
compile 'jp.wasabeef:picasso-transformations:1.2.0'
// If you want to use the GPU Filters
//compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
compile project(':appiraterAndroid')
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.teamhj.agriweather"
    minSdkVersion 16
    targetSdkVersion 21
    versionCode 1010
    versionName "1.0.10"
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true
}
buildTypes {

    debug {
        debuggable true
    }

    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        res.srcDirs = ['res']
    }
}

signingConfigs {
    debug {
        storeFile file('debug.keystore')
    }
}

}

task startDemo(type: Exec) {
dependsOn 'installDebug'
def adb = new File("${System.env.ANDROID_HOME}", "platform-tools${File.separator}adb")
commandLine adb, "shell", "am", "start", "-n", "com.google.maps.android.utils.demo/.MainActivity"
}

Cannot compile with proguard

Since #36 It throws an error compiling:

Warning:Exception while processing task java.io.IOException: proguard.ParseException: Unknown option 'com.squareup.okhttp' in line 3 of file '/Users/user/.gradle/caches/transforms-1/files-1.1/picasso-transformations-2.2.0.aar/16c5d97f0c603c4db20540986cd71722/proguard.txt'

In picasso-transformations/transformations/proguard-rules.txt it says:
-dontwarn dontwarn com.squareup.okhttp
I think it should be:
-dontwarn com.squareup.okhttp

RoundedCornersTransformation(int radius, int margin, CornerType cornerType) with picasso fit causing image overlapping

Using Picasso fitfunction along with RoundedCornersTransformation(int radius, int margin, CornerType cornerType) constructor result into overlapping images

Layout xml


   <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:gravity="center_horizontal" >

            <ImageView
                android:id="@+id/with_corner_type"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:background="#F00"
                android:gravity="center_horizontal"
                android:text="@string/hello_world" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/with_corner_type"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:text="With CornerType"
                android:textColor="#FFF" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:gravity="center_horizontal" >

            <ImageView
                android:id="@+id/without_corner_type"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:background="#F00"
                android:gravity="center_horizontal"
                android:text="@string/hello_world" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/without_corner_type"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:text="Without CornerType"
                android:textColor="#FFF" />
        </RelativeLayout>

Loading images with RoundedCornersTransformation

//Using fit without CornerType
Picasso.with(getApplicationContext()).load(R.drawable.kitten).fit().centerCrop()
                .transform(new RoundedCornersTransformation(50, 50))
                .into((ImageView) findViewById(R.id.without_corner_type));

//Using fit with CornerType
Picasso.with(getApplicationContext()).load(R.drawable.kitten).fit().centerCrop()
                .transform(new RoundedCornersTransformation(50, 50, CornerType.DIAGONAL_FROM_TOP_RIGHT))
                .into((ImageView) findViewById(R.id.with_corner_type));

Result :- The red color highlights actual size of imageView

fitwithcornertype

Cannot find the library in Gradle

hi,

Thanks for your awesome library.
But I have problems with integrate the lib into my app.
I tried to put this line
compile 'jp.wasabeef:picasso-transformations:2.1.0'

but nothing is downloaded. Can you give me some helps?
Thanks

CropCircleTransformation may be a singleton

CropCircleTransformation has no parameters, several instances are useless.
This class may provide a static getInstance() method and return the same instance every time, and thus public constructor should be deprecated.

StrictMode: A resource was acquired at attached stack trace but never released

RSBlur creates 4 Objects(2 Allocation, RenderScript and ScriptIntrinsicBlur) but it only destroys the RenderScript. This causes the resources to stick around and never get released. Calling destroy on all of those object in the finally clause fixes the issue.

I will try to find the time to make a PR.

Tested on a Nexus 6

Feature Request Change Specific color to transparent

Dear wasabeef,

I have some feature request.
I need to clean specific color and change it to transparent.
Could it be possible to implement new feature or any suggestion that I can modify your class?

I want to remain only radar stuff and change background and seashore lines to transparent..
So

change this
image

to this
image

I just want to set cleaned image to the overlay of google maps

Many Thanks for your great work!!

Add gpuimage-library dependency to POM

It would be nice if the POM included the gpuimage-library dependency, so that it will be downloaded automatically with picasso-transformations and we don't have to add that additional dependency to our projects.

BlurTransformation not work for me

already add renderscript in build.gradle:

 defaultConfig {
        applicationId "xxx"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        renderscriptSupportModeEnabled true
    }

when i build the project:

    Path in archive: lib/armeabi-v7a/libblasV8.so
Error:duplicate files during packaging of APK /Users/rowandjj/AndroidStudioProjects/PaimaiNews/app/build/outputs/apk/app-debug-unaligned.apk
    Origin 1: /Users/rowandjj/Library/Android/sdk/build-tools/23.0.1/renderscript/lib/packaged/armeabi-v7a/libblasV8.so
    Origin 2: /Users/rowandjj/AndroidStudioProjects/PaimaiNews/app/build/intermediates/exploded-aar/jp.wasabeef/picasso-transformations/1.3.0/jni/armeabi-v7a/libblasV8.so

so i exclude those .so file by packingOptions:

    packagingOptions{
        exclude 'lib/armeabi-v7a/libblasV8.so'
        exclude 'lib/armeabi-v7a/librsjni.so'
        exclude 'lib/armeabi-v7a/libRSSupport.so'
        exclude 'lib/mips/libblasV8.so'
        exclude 'lib/mips/librsjni.so'
        exclude 'lib/mips/libRSSupport.so'
        exclude 'lib/x86/libblasV8.so'
        exclude 'lib/x86/librsjni.so'
        exclude 'lib/x86/libRSSupport.so'
    }

but it not worked either.....

what should i do?

Build failed with duplicate libraries

Couldn't build my project with your library included.

Error:duplicate files during packaging of APK /app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: lib/armeabi-v7a/libblasV8.so
Origin 1: /app/build/intermediates/exploded-aar/jp.wasabeef/picasso-transformations/1.3.1/jni/armeabi-v7a/libblasV8.so
Origin 2: /build-tools/23.0.2/renderscript/lib/packaged/armeabi-v7a/libblasV8.so
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'lib/armeabi-v7a/libblasV8.so'
}
}
Error:Execution failed for task ':app:packageDebug'.

Duplicate files copied in APK lib/armeabi-v7a/libblasV8.so
File 1: /app/build/intermediates/exploded-aar/jp.wasabeef/picasso-transformations/1.3.1/jni/armeabi-v7a/libblasV8.so
File 2: /build-tools/23.0.2/renderscript/lib/packaged/armeabi-v7a/libblasV8.so

I tried excluding the lib from packaging options as suggested by the compiler, but it didn't work. That could be a problem on my end. I'll be going with another library in any case. I also tried

BlurTransform not working sometimes

I can't recognize what is going wrong please help.
My code :

`Picasso.with(PlayScreenActivity.this)
                    .load(uri)
                    .transform(new BlurTransformation(this,25,10))
                    .placeholder(R.drawable.ic_default)
                    .error(R.drawable.ic_default)
                    .into(new Target() {
                        @Override
                        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                        }

                        @Override
                        public void onBitmapFailed(Drawable errorDrawable) {
                        }

                        @Override
                        public void onPrepareLoad(Drawable placeHolderDrawable) {
                        }
                    });`

See the crashlytic log report

Fatal Exception: java.lang.RuntimeExceptionTransformation BlurTransformation(radius=25, sampling=10) crashed with exception. 

  | com.a.a.c$3.run (BitmapHunter.java:434)
  | android.os.Handler.handleCallback (Handler.java:739)
  | com.android.internal.os.ZygoteInit.main (ZygoteInit.java:779)

Caused by java.lang.IllegalArgumentException width and height must be > 0 
  | android.graphics.Bitmap.createBitmap (Bitmap.java:866)
  | android.graphics.Bitmap.createBitmap (Bitmap.java:812)
  | b.a.a.a.a.a (BlurTransformation.java:58)
  | com.a.a.c.a (BitmapHunter.java:429)
  | com.a.a.c.a (BitmapHunter.java:238)
  | com.a.a.c.run (BitmapHunter.java:159)
  | java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:422)
  | java.lang.Thread.run (Thread.java:818)
  | com.a.a.ah$d.run (Utils.java:411)

Need to apply effect on image and send to server

Hello,

Thanks for the library , this was what i needed!

It always go in onPrepareLoad and then onBitmapFailed! and errorDrawable is null.

Picasso.with(CameraActivity.this).load(filename)
.transform(new SwirlFilterTransformation(CameraActivity.this)).into(new Target() {
@OverRide
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
imageView.setImageBitmap(bitmap);
bmp = bitmap;
}

                @Override
                public void onBitmapFailed(Drawable errorDrawable) {

                }

                @Override
                public void onPrepareLoad(Drawable placeHolderDrawable) {

                }
            });

Crop Left

Hello,

I need doing crop the image left! Have any suggestions or solution?

CropTransformation.java sometimes crashes

.transform(new CropTransformation(1.2f, CropTransformation.GravityHorizontal.CENTER, CropTransformation.GravityVertical.TOP))

Fatal Exception: java.lang.RuntimeException
Transformation CropTransformation(width=600, height=451, mWidthRatio=0.0, mHeightRatio=0.0, mAspectRatio=1.33, gravityHorizontal=CENTER, mGravityVertical=TOP) crashed with exception.

Caused by java.lang.NullPointerException
android.graphics.Canvas. (Canvas.java:136)
jp.wasabeef.picasso.transformations.CropTransformation.transform (CropTransformation.java:301)
com.squareup.picasso.BitmapHunter.applyCustomTransformations (BitmapHunter.java:429)
com.squareup.picasso.BitmapHunter.hunt (BitmapHunter.java:238)
com.squareup.picasso.BitmapHunter.run (BitmapHunter.java:159)
java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:422)
java.lang.Thread.run (Thread.java:848)
com.squareup.picasso.Utils$PicassoThread.run (Utils.java:411)

CropCircleTransformation creates an extra Bitmap

I believe it's not necessary to create squaredBitmap. Instead, the BitmapShader can be given a Matrix that has setTranslate(-width, -height). This should accomplish the same thing that creating squaredBitmap does, shifting the viewport on source so that its centre is drawn into bitmap.

Crop not working as expected?

CropCenter isn't doing what I expect in the example app. The demo.jpg is 640x359 and the CropCenter example crops it to 300x100 center - I would expect the resulting image to just about cover the dogs' heads but it seems to be full width as you can see the red stripe on the far left of the first dog and the wicker basket on the shelf on the right?

What I expect it to look like:
demo_center_crop_300_100

Screenshot from demo app:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.