GlideWebpDecoder Documentation

repository·master·Indexed 21 days ago

https://github.com/zjupure/glidewebpdecoder

An Android Glide integration library that leverages libwebp to enable decoding and displaying of animated, transparent, or lossless WebP images. Includes guidance on Gradle installation, version matching with Glide, AndroidX compatibility, and using WebpDrawableTransformation for Bitmap transformations.

Tokens
699
Snippets
3
Records
3
Agent score
24%

What's inside GlideWebpDecoder

  1. Install GlideWebpDecoder via Gradle

    master

    GlideWebpDecoder is available on Maven Central. To integrate it, add mavenCentral() to your repositories and include the dependency in your build.gradle.

    Version Matching Rule: The version of webpdecoder must correspond to your glide version using the pattern {major_version}.{glide_version}. For example, if you use Glide 4.16.0, use webpdecoder:2.7.4.16.0.

    Compatibility Notes:

    • AndroidX: Since Glide 4.10.0, AndroidX is required. webpdecoder versions 1.6.{GLIDE_VERSION} and above support AndroidX and require Glide 4.10.0 or higher.
    • Legacy Versions: If you use a Glide version lower than 4.10.0, you must clone the project and modify it manually, as the library only follows the latest three Glide versions.
    def GLIDE_VERSION = "4.16.0"
    // webpdecoder
    implementation "com.github.zjupure:webpdecoder:2.7.${GLIDE_VERSION}"
    // glide 4.10.0+
    implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
    annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
  2. Use Bitmap transformations with WebpDrawable

    master

    When using standard Glide BitmapTransformation (or libraries like glide-transformations) with Webp images, you must wrap your original transformation in a WebpDrawableTransformation. This ensures that transformations are applied correctly to the WebP drawable.

    Transformation<Bitmap> circleCrop = new CircleCrop();
    GlideApp.with(mContext)
            .load(url)
            .optionalTransform(circleCrop)
            .optionalTransform(WebpDrawable.class, new WebpDrawableTransformation(circleCrop))
            .into(imageView);
  3. Configure Proguard for GlideWebpDecoder

    master

    Because the library uses native code (JNI) to decode WebP images, you must add specific rules to your proguard.cfg to prevent the JNI interfaces from being obfuscated or removed during the build process.

    -keep public class com.bumptech.glide.integration.webp.WebpImage { *; }
    -keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }
    -keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }