项目作者: wasabeef

项目描述 :
An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.
高级语言: Kotlin
项目地址: git://github.com/wasabeef/transformers.git
创建时间: 2019-10-25T15:53:40Z
项目社区:https://github.com/wasabeef/transformers

开源协议:Apache License 2.0

下载















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

  1. repositories {
  2. mavenCentral()
  3. }

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

For Coil

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

For Glide

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

For Picasso

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

For Fresco

  1. dependencies {
  2. implementation 'jp.wasabeef.transformers:fresco:1.0.6'
  3. // Use the GPU Filters
  4. implementation 'jp.wasabeef.transformers:fresco-gpu:1.0.6'
  5. }
  1. val request: ImageRequest =
  2. ImageRequestBuilder.newBuilderWithSource(IMAGE_URL.toUri())
  3. .setPostprocessor(BlurPostprocessor(context, 25, 4))
  4. .build()
  5. holder.image.controller = Fresco.newDraweeControllerBuilder()
  6. .setImageRequest(request)
  7. .setOldController(draweeView.controller)
  8. .build()

With Jetpack Compose

Use Composable Images when using with Jetpack Compose.

  1. GlideImage(
  2. model = IMAGE_URL,
  3. modifier = Modifier.preferredWidth(120.dp),
  4. options = RequestOptions().transform(
  5. BlurTransformation(context, radius = 25, sampling = 4)
  6. )
  7. )

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

  1. $ npm install

Build

  1. $ ./gradlew assemble

Formatting

  1. $ ./gradlew ktlint

Publishing to Maven Central

  1. $ ./gradlew :core:clean :core:build :core:publish
  2. ....
  3. ....