Encode Gif to Base64
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
I'm trying to encode an an animated Gif to base64 so I can upload it from an Android app to my server, where I'll decode it and save it as a file.
I've used this code:
(ImagePath is a TextView that holds the path to the GIF on my device)
I'm using Glide v4.11.0.
```
Glide.with(context)
.as(byte[].class)
.load(imagePath.getText().toString())
.into(new CustomTarget() {
@Override
public void onResourceReady(@NonNull byte[] resource, @Nullable Transition transition) {
String attachImage = Base64.encodeToString(resource,
Base64.NO_WRAP);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
```
But when it submits to my server and I convert to a file, it doesn't animate. I'm unsure if it's the code above that is only encoding the first frame, or if it is something I am doing on my server when decoding and saving the file that is the issue. So I wanted to check if my above code is correct for converting an animated Gif to base64.
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.