Giter Site home page Giter Site logo

wasabeef / transformers Goto Github PK

View Code? Open in Web Editor NEW
293.0 7.0 14.0 51.23 MB

An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.

Home Page: https://github.com/wasabeef/transformers

License: Apache License 2.0

Kotlin 100.00%
android coil glide picasso fresco gpuimage transformation image-processing

transformers's Introduction

What is Transformers?

An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.


Part of the sample


Glide Transformations, Picasso Transformations, Fresco Processors are deprecated.
Development will stop soon.. For an up-to-date version, please use this.

Installation

Requirements

  • Android 5.0+ Lollipop (API level 21)

Gradle settings

repositories {
  mavenCentral()
}

This Transformer is NOT using android.support.v8.rendererscript because librs.so make the APK file too big.

For Coil

dependencies {
  implementation 'jp.wasabeef.transformers:coil:1.0.6'
  // Use the GPU Filters 
  implementation 'jp.wasabeef.transformers:coil-gpu:1.0.6'
}
imageView.load(IMAGE_URL) {
  transformations(
    CropCenterTransformation(),
    RoundedCornersTransformation(radius = 120, cornerType = CornerType.DIAGONAL_FROM_TOP_LEFT)
  )
}

For Glide

dependencies {
  implementation 'jp.wasabeef.transformers:glide:1.0.6'
  // Use the GPU Filters 
  implementation 'jp.wasabeef.transformers:glide-gpu:1.0.6'
}
Glide.with(context)
  .load(IMAGE_URL)
  .apply(
    bitmapTransform(
      MultiTransformation(
        CropCenterTransformation(),
        BlurTransformation(context, 15, sampling = 1)
      )
    )
  ).into(imageView)

For Picasso

dependencies {
  implementation 'jp.wasabeef.transformers:picasso:1.0.6'
  // Use the GPU Filters 
  implementation 'jp.wasabeef.transformers:picasso-gpu:1.0.6'
}
Picasso.get()
  .load(IMAGE_URL)
  .fit().centerInside()
  .transform(
    mutableListOf(
      CropCenterTransformation(),
      BlurTransformation(context, 25, sampling = 4)
    )
  ).into(imageView)

For Fresco

dependencies {
  implementation 'jp.wasabeef.transformers:fresco:1.0.6'
  // Use the GPU Filters 
  implementation 'jp.wasabeef.transformers:fresco-gpu:1.0.6'
}
val request: ImageRequest =
  ImageRequestBuilder.newBuilderWithSource(IMAGE_URL.toUri())
  .setPostprocessor(BlurPostprocessor(context, 25, 4))
  .build()

holder.image.controller = Fresco.newDraweeControllerBuilder()
  .setImageRequest(request)
  .setOldController(draweeView.controller)
  .build()

With Jetpack Compose

Use Composable Images when using with Jetpack Compose.

GlideImage(
  model = IMAGE_URL,
  modifier = Modifier.preferredWidth(120.dp),
  options = RequestOptions().transform(
    BlurTransformation(context, radius = 25, sampling = 4)
  )
)

Sample transformations

Original Mask NinePatchMask CropTop
CropCenter CropBottom CropCenterRatio16x9 CropCenterRatio4x3
CropTopRatio16x9 CropBottomRatio4x3 CropSquare CropCircle
CropCircleWithBorder ColorFilter Grayscale RoundedCorners
RoundedCornersTopLeft RSGaussianBlurLight RSGaussianBlurDeep StackBlurLight
StackBlurDeep

coil, glide, picasso

  • BlurTransformation
  • ColorFilterTransformation
  • CropCenterBottomTransformation
  • CropCenterTopTransformation
  • CropCenterTransformation
  • CropCircleTransformation
  • CropCircleWithBorderTransformation
  • CropSquareTransformation
  • CropTransformation
  • GrayscaleTransformation
  • MaskTransformation
  • RoundedCornersTransformation

fresco

  • BlurPostprocessor
  • ColorFilterPostprocessor
  • CombinePostProcessors
  • GrayscalePostprocessor
  • MaskPostprocessor

Sample transformations with GPUImage

We recommend that you have a ToneCurve file, as you can apply any filters you like.

Original Sepia Contrast Invert
PixelLight PixelDeep Sketch Swirl
Brightness Kuawahara Vignette ZoomBlur
WhiteBalance Halftone Sharpness Toon
ToneCurve

coil-gpu, glide-gpu, picasso-gpu

  • BrightnessFilterTransformation
  • ContrastFilterTransformation
  • HalftoneFilterTransformation
  • InvertFilterTransformation
  • KuwaharaFilterTransformation
  • PixelationFilterTransformation
  • SepiaFilterTransformation
  • SharpenFilterTransformation
  • SketchFilterTransformation
  • SwirlFilterTransformation
  • ToneCurveFilterTransformation
  • ToonFilterTransformation
  • VignetteFilterTransformation
  • WhiteBalanceFilterTransformation
  • ZoomBlurFilterTransformation

fresco-gpu

  • BrightnessFilterPostprocessor
  • ContrastFilterPostprocessor
  • HalftoneFilterPostprocessor
  • InvertFilterPostprocessor
  • KuwaharaFilterPostprocessor
  • PixelationFilterPostprocessor
  • SepiaFilterPostprocessor
  • SharpenFilterPostprocessor
  • SketchFilterPostprocessor
  • SwirlFilterPostprocessor
  • ToneCurveFilterPostprocessor
  • ToonFilterPostprocessor
  • VignetteFilterPostprocessor
  • WhiteBalanceFilterPostprocessor
  • ZoomBlurFilterPostprocessor

Development

Setup

Things you will need

$ npm install

Build

$ ./gradlew assemble

Formatting

$ ./gradlew ktlint

Publishing to Maven Central

$ ./gradlew :core:clean :core:build :core:publish
....
....

transformers's People

Contributors

mori-atsushi avatar wasabeef 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

transformers's Issues

Transformer is not compatible with coil 2.0

Coil will make a big breaking change in 2.0.
Now, many Transformation for Coil, including BlurTransformation, throw an AbstractMethodError and do not work with Coil 2.0.

At least the following two changes are required.

  • Transformation.key is replaced with Transformation.cacheKey.
  • BitmapPool and PoolableViewTarget have been removed from the library.

Since Coil 2.0 is alpha, it may changes until the stable release.

Can I make a Pull Request?

Problems encountered using glide transformation

Thank you for the glide transformation library,
I encountered a tough problem when using the glide blur transformation method,
if you have time, can you tell me what is the reason...Thanks a million!!

Here is the stack trace:

11-30 19:29:17.687: A/DEBUG(20661): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-30 19:29:17.687: A/DEBUG(20661): Build fingerprint: 'google/redfin_64/redfin:13/TP1A.220624.014/8819323:userdebug/dev-keys'
11-30 19:29:17.687: A/DEBUG(20661): Revision: 'MP1.0'
11-30 19:29:17.687: A/DEBUG(20661): ABI: 'arm64'
11-30 19:29:17.687: A/DEBUG(20661): Timestamp: 2022-11-30 19:29:16.492229176-0800
11-30 19:29:17.687: A/DEBUG(20661): Process uptime: 9s
11-30 19:29:17.688: A/DEBUG(20661): Cmdline: xxxx.xxxx.xxxx
11-30 19:29:17.688: A/DEBUG(20661): pid: 19825, tid: 20637, name: glide-source-th  >>> xxxx.xxxx.xxxx <<<
11-30 19:29:17.688: A/DEBUG(20661): uid: 10264
11-30 19:29:17.688: A/DEBUG(20661): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000
11-30 19:29:17.688: A/DEBUG(20661): Cause: null pointer dereference
11-30 19:29:17.688: A/DEBUG(20661):     x0  0000000000000000  x1  0000000000000000  x2  00000070171132c4  x3  0000000000000004
11-30 19:29:17.688: A/DEBUG(20661):     x4  0000000000000004  x5  0000000000000000  x6  ff7b7070ff7b7070  x7  ff7b706fff7b7070
11-30 19:29:17.688: A/DEBUG(20661):     x8  0000006f6622b53c  x9  a834832689f6064a  x10 0000000000000000  x11 0000000000000665
11-30 19:29:17.688: A/DEBUG(20661):     x12 0000000080d95f72  x13 ff7b706fff7b7070  x14 0000000000000001  x15 b4000070157b7044
11-30 19:29:17.688: A/DEBUG(20661):     x16 0000006f67ba9c40  x17 0000006f67b99fe4  x18 0000007016f3c000  x19 0000007017114000
11-30 19:29:17.688: A/DEBUG(20661):     x20 b4000071acedc6c0  x21 b4000071acedcc20  x22 0000007017113318  x23 b4000071acedcc50
11-30 19:29:17.688: A/DEBUG(20661):     x24 0000000000000001  x25 00000000ffffffff  x26 0000000000000000  x27 0000000000000008
11-30 19:29:17.688: A/DEBUG(20661):     x28 0000006f67baaea0  x29 00000070171132d0
11-30 19:29:17.688: A/DEBUG(20661):     lr  0000006f67b9a02c  sp  00000070171132c0  pc  0000006f6622b54c  pst 0000000020000000
11-30 19:29:17.688: A/DEBUG(20661): backtrace:
11-30 19:29:17.688: A/DEBUG(20661):       #00 pc 000000000001e54c  /apex/com.android.vndk.v33/lib64/libRSDriver.so (rsdScriptSetGlobalVar(android::renderscript::Context const*, android::renderscript::Script const*, unsigned int, void*, unsigned long)+16) (BuildId: cfdd713285af66dd4339fd9a98e84678)
11-30 19:29:17.688: A/DEBUG(20661):       #01 pc 000000000003c028  /apex/com.android.vndk.v33/lib64/libRS_internal.so (android::renderscript::rsi_ScriptSetVarF(android::renderscript::Context*, void*, unsigned int, float)+68) (BuildId: e5e4d6e722fa1a66ebc31128336a8992)
11-30 19:29:17.688: A/DEBUG(20661):       #02 pc 00000000000427ac  /apex/com.android.vndk.v33/lib64/libRS_internal.so (android::renderscript::ThreadIO::playCoreCommands(android::renderscript::Context*, int)+364) (BuildId: e5e4d6e722fa1a66ebc31128336a8992)
11-30 19:29:17.688: A/DEBUG(20661):       #03 pc 000000000002c47c  /apex/com.android.vndk.v33/lib64/libRS_internal.so (android::renderscript::Context::threadProc(void*)+2340) (BuildId: e5e4d6e722fa1a66ebc31128336a8992)
11-30 19:29:17.688: I/A(5937): #shareData for GellerAiAiDataShare_shareData_GELLER_CONFIG with pending task count: 0
11-30 19:29:17.688: A/DEBUG(20661):       #04 pc 00000000000b62b8  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 058e3ec96fa600fb840a6a6956c6b64e)
11-30 19:29:17.688: A/DEBUG(20661):       #05 pc 0000000000052fb8  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 058e3ec96fa600fb840a6a6956c6b64e)

CropCircleWithBorderTransformation

CropCircleWithBorderTransformation when calculating the border there is a bug.
If the width and height of the picture are not equal, then the width of the outer border is set to be wider than the actual value.

bugs

Code :

        val url = "https://pic.52112.com/JPG-180507/180507_295/hILItGsZAG_small.jpg"
        viewBinding.ivImage.load(url) {
            transformations(CropCircleWithBorderTransformation(10.dp, "#00ff00".toColorInt()))
        }

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.