forked from LedFx/LedFx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'LedFx:main' into webaudio-base64
- Loading branch information
Showing
16 changed files
with
140 additions
and
312 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
from enum import Enum | ||
|
||
import voluptuous as vol | ||
from PIL import Image | ||
|
||
from ledfx.effects import Effect | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class GIFResizeMethods(Enum): | ||
# https://pillow.readthedocs.io/en/stable/handbook/concepts.html#filters-comparison-table | ||
NEAREST = "Fastest" | ||
BILINEAR = "Fast" | ||
BICUBIC = "Slow" | ||
LANCZOS = "Slowest" | ||
|
||
|
||
@Effect.no_registration | ||
class GifBase(Effect): | ||
""" | ||
Simple Gif base class that supplies basic gif and resize capability. | ||
""" | ||
|
||
RESIZE_METHOD_MAPPING = { | ||
GIFResizeMethods.NEAREST.value: Image.NEAREST, | ||
GIFResizeMethods.BILINEAR.value: Image.BILINEAR, | ||
GIFResizeMethods.BICUBIC.value: Image.BICUBIC, | ||
GIFResizeMethods.LANCZOS.value: Image.LANCZOS, | ||
} | ||
|
||
CONFIG_SCHEMA = vol.Schema( | ||
{ | ||
vol.Optional( | ||
"resize_method", | ||
description="What strategy to use when resizing GIF", | ||
default=GIFResizeMethods.BICUBIC.value, | ||
): vol.In( | ||
[resize_method.value for resize_method in GIFResizeMethods] | ||
), | ||
} | ||
) | ||
|
||
def config_updated(self, config): | ||
self.resize_method = self.RESIZE_METHOD_MAPPING[ | ||
self._config["resize_method"] | ||
] |
Oops, something went wrong.