DiverOfDark / KNOMI

Alternative opinionated firmware for Knomi devices
19 stars 0 forks source link

Feature: Optimise images at build #46

Open jMaddrell opened 8 months ago

jMaddrell commented 8 months ago

Images currently in the repo have been compressed to preserve space

jMaddrell commented 8 months ago

The GCE block (Graphic Control Extension) in each frame controls how long it is displayed for, the source images have duplicate frames to control animation times. They could potentially be removed by crafting the metadata for each frame. This would allow the AP_Config to be restored as well.

DiverOfDark commented 8 months ago

Also for the newer / alternative images we need to optimize / crop each frame. In original images each frame have different size and different offset. I was able to write some kind of Py script to repro that behavior, but not completed it fully - need to check pixel boundaries not against bg color, but against previous frame. The thing is, pygif library provides really nice low-lever api for gif editing - so that you could, for example, reogranize frames/delays as you wish. Here's what I have crafted so far - https://gist.github.com/DiverOfDark/bdcb5fddb2499d465f2a312d2f03a585

jMaddrell commented 8 months ago

I've tried to use imagemagick to remove the duplicate frames but they are different enough that it doesn't remove anything. Will take a look into the custom script approach.

jMaddrell commented 8 months ago

It may be worth removing the black background from the stock images, this would allow users to change the background colour themselves.

DiverOfDark commented 8 months ago

2 concerns about transparent gifs: