LOOHP / ImageFrame

Put images on maps and walls!
https://www.spigotmc.org/resources/106031/
GNU General Public License v3.0
40 stars 12 forks source link

Delayed animated gifs are incredibly inefficient storage-wise #50

Closed EpicKnarvik97 closed 1 month ago

EpicKnarvik97 commented 2 months ago

I wanted to use an animated .gif for displaying information, as the information wouldn't fit on a single reasonably-sized image frame, and I didn't have enough space in the area I wanted to place it. The .gif has 6 individual pictures with 15 seconds of wait time between each image change. It is rendered on image frames 5 wide and 4 tall. I would expect this to produce about 120 picture files, if every individual picture was split into 20 parts. Instead, it is stored as 46020 image files (88.4MB instead of the gif's original 172KB). It stores the entire 5x4 picture 2301 times. 45900 images are duplicates of other images.

I guess the problem is that one "snapshot" of the animation is taken for every frame ImageFrame is to render, not accounting for the existence of .gif delay. There must be a better way, by storing the .gif timing data, and only each unique image.

Animated .gif for debugging purposes: FactionInfo

LOOHP commented 1 month ago

Please give build #100 a try.

EpicKnarvik97 commented 1 month ago

In build #100 (and #102 as well), the animated .gif is treated as a normal image instead of an animated one. Only the first frame is converted into 20 images. The remaining 5 frames are lost.

LOOHP commented 1 month ago

I tested with the direct link of the image above on a 4 x 3 size and it worked. Before that, I was uploading it to imgbb and realized they removed the remaining 5 frames on their end.

EpicKnarvik97 commented 1 month ago

Ok. It works. I found out that in my case it was a permission issue, as I set my ImageFrame permissions to that of a normal player after the initial setup.

I'd suggest adding a message when an animated .gif is turned into a normal image because of missing animated permission, if it isn't too much of a hassle. Or perhaps the image creation should be denied instead. I, at least, found it confusing when the behavior changed without any indication of why.