Transformers
An Android transformation library providing a variety of image transformations for Coil, Glide, Picasso, and Fresco.
Install / Use
/learn @wasabeef/TransformersREADME
What is Transformers?
An Android transformation library providing a variety of image transformations for [Coil], [Glide], [Picasso], and [Fresco].
<a href="https://github.com/coil-kt/coil"> <img src="https://github.com/wasabeef/transformers/raw/main/art/coil.png" width="58px"/> </a> <a href="https://github.com/bumptech/glide"> <img src="https://github.com/wasabeef/transformers/raw/main/art/glide.png" width="64px"/> </a> <a href="https://github.com/square/picasso"> <img src="https://github.com/wasabeef/transformers/raw/main/art/picasso.jpg" width="64px"/> </a> <a href="https://github.com/facebook/fresco"> <img src="https://github.com/wasabeef/transformers/raw/main/art/fresco.png" width="64px"/> </a> <a href="https://developer.android.com/jetpack/compose"> <img src="https://github.com/wasabeef/transformers/raw/main/art/jetpack-compose.svg" width="100px"/> </a> <br>Part of the sample
<img src="https://github.com/wasabeef/transformers/raw/main/art/Original.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/Mask.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/CropCircle.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/RSGaussianBlurDeep.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/RoundedCornersTopLeft.png" width="120px" />
<img src="https://github.com/wasabeef/transformers/raw/main/art/PixelDeep.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/ZoomBlur.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/Kuawahara.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/Vignette.png" width="120px" /> <img src="https://github.com/wasabeef/transformers/raw/main/art/ToneCurve.png" width="120px" />
<br>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] <a href="https://github.com/coil-kt/coil"><img src="https://github.com/wasabeef/transformers/raw/main/art/coil.png" width="12px"/></a>
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] <a href="https://github.com/bumptech/glide"><img src="https://github.com/wasabeef/transformers/raw/main/art/glide.png" width="12px"/></a>
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] <a href="https://github.com/square/picasso"><img src="https://github.com/wasabeef/transformers/raw/main/art/picasso.jpg" width="12px"/></a>
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] <a href="https://github.com/facebook/fresco"><img src="https://github.com/wasabeef/transformers/raw/main/art/fresco.png" width="12px"/></a>
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 | |:---:|:---:|:---:|:---:| | <img src="https://github.com/wasabeef/transformers/raw/main/art/Original.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Mask.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/NinePatchMask.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropTop.png" width="120px" /> | | CropCenter | CropBottom | CropCenterRatio16x9 | CropCenterRatio4x3 | | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropCenter.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropBottom.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropCenterRatio16x9.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropCenterRatio4x3.png" width="120px" /> | | CropTopRatio16x9 | CropBottomRatio4x3 | CropSquare | CropCircle | | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropTopRatio16x9.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropBottomRatio4x3.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropSquare.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropCircle.png" width="120px" /> | | CropCircleWithBorder | ColorFilter | Grayscale | RoundedCorners | | <img src="https://github.com/wasabeef/transformers/raw/main/art/CropCircleWithBorder.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/ColorFilter.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Grayscale.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/RoundedCorners.png" width="120px" /> | | RoundedCornersTopLeft | RSGaussianBlurLight | RSGaussianBlurDeep | StackBlurLight | | <img src="https://github.com/wasabeef/transformers/raw/main/art/RoundedCornersTopLeft.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/RSGaussianBlurLight.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/RSGaussianBlurDeep.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/StackBlurLight.png" width="120px" /> | | StackBlurDeep | | <img src="https://github.com/wasabeef/transformers/raw/main/art/StackBlurDeep.png" width="120px" /> |
<kbd>coil</kbd>, <kbd>glide</kbd>, <kbd>picasso</kbd>
- BlurTransformation
- ColorFilterTransformation
- CropCenterBottomTransformation
- CropCenterTopTransformation
- CropCenterTransformation
- CropCircleTransformation
- CropCircleWithBorderTransformation
- CropSquareTransformation
- CropTransformation
- GrayscaleTransformation
- MaskTransformation
- RoundedCornersTransformation
<kbd>fresco</kbd>
- 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 | |:---:|:---:|:---:|:---:| | <img src="https://github.com/wasabeef/transformers/raw/main/art/Original.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Sepia.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Contrast.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Invert.png" width="120px" /> | | PixelLight | PixelDeep | Sketch | Swirl | | <img src="https://github.com/wasabeef/transformers/raw/main/art/PixelLight.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/PixelDeep.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Sketch.png" width="120px" /> | <img src="https://github.com/wasabeef/transformers/raw/main/art/Swirl.png" width="120px" /> | | Brightness | Kuawahara | Vignette | ZoomBlur | |
