GithubHelp home page GithubHelp logo

Comments (5)

colinrtwhite avatar colinrtwhite commented on August 15, 2024 2

Unfortunately, this isn't very straightforward to support. Fresco uses native libraries to load animated WebP images on pre-Android P, which I'm against adding to the Coil main repo.

I think this would be a good candidate for an external repository that depends Coil. If anyone writes a Decoder for this, let me know and I'll add it to the documentation.

from coil.

skgmn avatar skgmn commented on August 15, 2024

Hello @colinrtwhite! It's quite long ago, but I've done this recently using libwebp so I'm just letting you know as you said. 🙂
Check this out: https://github.com/skgmn/AnimatedWebPDecoder
Thank you.

from coil.

ShowMeThe avatar ShowMeThe commented on August 15, 2024

Hi @colinrtwhite
I suggest this repository https://github.com/penfeizhou/APNG4Android
we can decode Animated PNG and Animated Webp by using the code(Only Java code , no C,C++ ) from this repository and make a custom Coil's Decoder ourselves.
My Coil's decoder bases on Coil's 2.0.0-alpha01

Here is my demo:
AnimatedWebPDrawable-Release.zip
Here is my demo link : https://github.com/ShowMeThe/AnimatedWebPDrawable

The testing on phone :
testing-animation
The left one is Coil's Decoder using code from APNG4Android repository , the right side is using Android Api ImageDecoder.decodeDrawable

Will it help Coil to support the Animated-webp or Animater-Png ?
Thanks you.

from coil.

colinrtwhite avatar colinrtwhite commented on August 15, 2024

@skgmn Sorry for the late reply, this looks awesome! I'll set up a list of external libraries and add it to the list.

@ShowMeThe Thanks for letting me know about this library! It looks like it could work well with Coil 2.0, which exposes ImageSource.file(). Bonus that it's an 100% Java solution.

from coil.

colinrtwhite avatar colinrtwhite commented on August 15, 2024

@ShowMeThe I think it might be possible to simplify your animated WebP decoder to just:

class AnimatedWebPDecoder(private val source: ImageSource) : Decoder {

    override suspend fun decode(): DecodeResult {
        return DecodeResult(
            drawable = WebPDrawable.fromFile(source.file().path),
            isSampled = false
        )
    }

    class Factory : Decoder.Factory {

        override fun create(result: SourceResult, options: Options, imageLoader: ImageLoader): Decoder? {
            if (WebPParser.isAWebP(result.source.file().path)) {
                return AnimatedWebPDecoder(result.source)
            } else {
                return null
            }
        }
    }
}

Though, I haven't tested the above code out.

from coil.

Related Issues (20)

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.