Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIF suppport #12

Closed
filwiesner opened this issue Jan 8, 2022 · 18 comments
Closed

GIF suppport #12

filwiesner opened this issue Jan 8, 2022 · 18 comments
Labels
enhancement New feature or request
Milestone

Comments

@filwiesner
Copy link

Does Kamel support GIFs (animated image)? I couldn't find any mention of it in README or using repository search.

@alialbaali
Copy link
Member

No it doesn't. The reason is that Kamel focuses more on Desktop than Android. You can see this issue which has a sample about a GIF Composable, however, last time I tested it, the performance was terrible. And that's the reason, Kamel doesn't support loading GIFs yet.

@alialbaali alialbaali added the enhancement New feature or request label Jul 23, 2022
@DRSchlaubi
Copy link

Any updates?

@luca992
Copy link
Member

luca992 commented May 31, 2023

@DRSchlaubi If you or someone else creates a pr with animated image support I can take a look. I don't have time to look into it atm

@PMARZV
Copy link

PMARZV commented Dec 21, 2023

any updates on this?? this could be a game changer! Btw this library is far better than coil imo, had a lot of problems and when i changed to this one for my multiplatform migration, all the problems disappeared!!! Congrats on the library!

@luca992
Copy link
Member

luca992 commented Dec 22, 2023

I still don't have time at the moment. Prs are welcome

@luca992
Copy link
Member

luca992 commented Mar 14, 2024

Next release should have support for gifs 👍

Screen.Recording.2024-03-14.at.6.36.31.AM.mov

@luca992 luca992 added this to the v1.0 milestone Mar 14, 2024
@luca992
Copy link
Member

luca992 commented Mar 14, 2024

released in v1.0.0-beta.5 lmk if there a problems... as I've only tested with a single gif 😅

@PMARZV
Copy link

PMARZV commented Mar 14, 2024

testing it tomorrow

@PMARZV
Copy link

PMARZV commented Mar 15, 2024

i have tested it and i works perfectly.

I have noticed that when using "media.kamel:kamel-image-default:1.0.0-beta.5" in common main and targeting only (for example) desktop, the build fails because it doesnt find "io.ktor:ktor-client-core:3.0.0-wasm2" (even though im not targeting wasm), it only works after adding "maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")" to dependencyResolutionManagement in settings gradle.
I have then tested to add the same Kamel dependency to an android project and same thing.

Btw minSdk = 28 in android, that must be because you require something that its not available in lower versions right?
(Error: uses-sdk:minSdkVersion 21 cannot be smaller than version 28 declared in library [media.kamel:kamel-decoder-animated-image-android:1.0.0-beta.5])

Without these issues, everything is working as expected!

@luca992
Copy link
Member

luca992 commented Mar 15, 2024

@PMARZV Yeah I'm still waiting for a non-experimental ktor build with wasm support. Didn't realize it would require consumers of the library to have to add that repo though. On the stable 0.9.x branch I'm still keeping wasm and non-wasm builds separate so the the non-wasm build can have a stable ktor... But for the beta, I just don't want to deal with it haha. I'm just going to keep it beta until a non-experimental ktor build is out.

And unfortunately, the skia rendering implementation is not available on android... and AndroidAnimatedImage is API level 28.

There's probably a way to make android decoder that supports API level 21 by adding a dependency (or writing something custom)... but I probably would make that a separate android only decoder. If anyone wants to make a pr to figure that out, be my guest.

@fluxxion82
Copy link

@luca992 I'm trying to display a gif that I have in my common resources:

KamelImage(
        resource = {
            asyncPainterResource(Res.drawable.logo_animated_gif)
        },
        modifier = modifier,
        contentDescription = "logo",
    )

but not seeing anything show up in my apps. I'm using version 1.0.0-beta.7 with dependencies kamel-image and kamel-decoder-animated-image. Am I missing anything? I've also tried to passing in the path of my gif to asyncPainterResource as well with no luck.

@luca992
Copy link
Member

luca992 commented Sep 14, 2024

@fluxxion82 does the file have a .gif extension? Currently picking a decoder is done by the file extension. Also, you can try printing any error with the onFailure handler to see what might be failing if anything

@fluxxion82
Copy link

@luca992 yes, the file has a .gif extension. I'm getting the following error from the onFailure handler:

IllegalStateException
java.lang.IllegalStateException: Unable to find a fetcher for class org.jetbrains.compose.resources.DrawableResource
at io.kamel.core.utils.ConfigUtilsKt.findFetcherFor(ConfigUtils.kt:32)
at io.kamel.core.ImageLoadingKt$loadImageBitmapResource$$inlined$loadResource$1.invokeSuspend(ImageLoading.kt:82)
at io.kamel.core.ImageLoadingKt$loadImageBitmapResource$$inlined$loadResource$1.invoke(Unknown Source:8)
at io.kamel.core.ImageLoadingKt$loadImageBitmapResource$$inlined$loadResource$1.invoke(Unknown Source:4)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)
at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:226)
at kotlinx.coroutines.flow.FlowKt__ErrorsKt.catchImpl(Errors.kt:152)
at kotlinx.coroutines.flow.FlowKt.catchImpl(Unknown Source:1)
at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:109)
at androidx.compose.runtime.SnapshotStateKt__SnapshotFlowKt$collectAsState$1$1$2.invokeSuspend(SnapshotFlow.kt:70)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:96)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:816)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)

@luca992
Copy link
Member

luca992 commented Sep 16, 2024

@fluxxion82 oh I see. There is not currently a compose multiplatform DrawableResource fetcher implementation made. I kinda halfway made the logic for it that would be needed if you want to make your own fetcher for it here: https://github.com/Kamel-Media/Kamel/blob/main/kamel-samples/src/commonMain/kotlin/io/kamel/samples/FileSample.kt

@luca992
Copy link
Member

luca992 commented Sep 16, 2024

This was all made before compose multiplatform resources was even a thing. So that will have to go on the todo list. Prs are welcome though.

Right now we only have standard jvm, and android resource fetchers made.

@fluxxion82
Copy link

@luca992 ok, thanks. I got the gif working on android but running into a number of issues when trying to run on iOS. also, when I use `asyncPainterResource("drawable/logo_animated.gif") instead of trying to use the DrawableResource, I get this exception:

java.net.ConnectException ``` java.net.ConnectException: Connection refused at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:762) at io.ktor.network.sockets.SocketImpl.connect$ktor_network(SocketImpl.kt:50) at io.ktor.network.sockets.SocketImpl$connect$1.invokeSuspend(Unknown Source:15) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:96) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:816) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707) ```
which I found odd since I'm not making any network requests.

when I model things after the FileSample code, I get some errors with iOS, namely some KLIB resolver: Could not find "org.jetbrains.kotlinx:kotlinx-io-bytestring" errors (i think i saw these when i tried to rebuild the project too), and I'm wondering if it has something to do with the kotlin version I'm using (2.0.20). Even when I built a version of kamel with updates to lib versions (compose, ktor, kotlin), I saw some other errors (ie kotlin.native.internal.IrLinkageError).

I might try to take another shot at getting things to work on iOS. if you have any insights into any of the issues I've mentioned, let me know.

@luca992
Copy link
Member

luca992 commented Sep 17, 2024

"drawable/logo_animated.gif" isn't a valid way to get a resource. You have to use the Int id on android. If you wanted to try do something like "drawable/logo_animated.gif" you'd need to make your own string mapper

@luca992
Copy link
Member

luca992 commented Sep 17, 2024

And idk. I can't help with your other issues without a way to duplicate it.

@luca992 luca992 closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants