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

[Suggestion] Merging images #2

Open
Lacie295 opened this issue Mar 25, 2019 · 5 comments
Open

[Suggestion] Merging images #2

Lacie295 opened this issue Mar 25, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@Lacie295
Copy link

Lacie295 commented Mar 25, 2019

Adding the possibilty to post multiple emotes in a single merged image/gif would be a nice feature. Something of the order of

yentPepoGun:yentBlobGun

could work for this

@Yentis Yentis added the enhancement New feature or request label Apr 2, 2021
@aketawi
Copy link

aketawi commented Apr 14, 2021

+1 for this idea. Perhaps just having several emotes, so yentPepoGun yentBlobGun would merge these two into one image (or gif if one or several of those was animated)
Would probably be a pain to implement this, but hey, the rest of the plugin is already glorious

@Mattwmaster58
Copy link

Mattwmaster58 commented Nov 30, 2021

I think I could add this with some good ole canvas image composition.

Working with images on the canvas isn't that bad for static images IMO. For gifs, it should be technically possible (anything is ;)), but to do it all in JS, performantly, would be a huge pain, for example, stringing them together in a way that they all appear coherently. If gif A has 41 frames forming one perfect loop, and gif B has 55 frames forming a perfect loop, and gif C has 13 frames forming a perfect loop, you'll need 29,315 frames to loop it all perfectly in a perfect gif. And of course there's heuristics you could take to try and cut the gif at less destructive points, but it would be complicated and janky to do this the "right" way, no matter how you define "right" IMO.

I was able to put this together: https://jsfiddle.net/m28djz1c/. Obviously extremely jank (images aren't sorted, aren't split up etc), but that's the nature of a PoC.

Is anyone able to test at what point emotes starting wrapping on small screens? I'd want to stay as close to a native experience as possible. I think some simple logic to split up the images into eg, chunks of 3 so that they render semi-nicely on mobile would be nice.

@Yentis
Copy link
Owner

Yentis commented Nov 30, 2021

I think something like Rust and compiling to WASM for performance might be an option, no idea if that will work with a BD plugin as I haven't tested it but yeah trying to manipulate gifs decently is a large pain.
FYI gif processing happens here: https://github.com/Yentis/betterdiscord-emotereplacer/blob/master/src/services/gifsicleService.ts

@Mattwmaster58
Copy link

Hmm, come to think of it, as gifs are generally small already, you may be able to line them up like I described earlier, and then maybe do min(lcm(...framerates), maxframerate*2) frames, then interpolate the gifs with less frames for the other GIFs.

@Mattwmaster58
Copy link

This is definitely possible with static images, but I think it would be a little trickier to do robustly. I might try my hand at doing it in a simpler plugin first

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

4 participants