From 712dc5f7b89ac00aa8bfd81fb7ae2b2f560d6b25 Mon Sep 17 00:00:00 2001 From: davidovski Date: Mon, 1 Nov 2021 22:53:48 +0000 Subject: made images smaller --- gif.py | 14 +++++++------- images/remotecontrol-small.png | Bin 0 -> 15993 bytes images/remotecontrol.png | Bin 5017 -> 18514 bytes 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 images/remotecontrol-small.png diff --git a/gif.py b/gif.py index df416f4..7aa4b61 100644 --- a/gif.py +++ b/gif.py @@ -28,8 +28,8 @@ sorted(colors, key=rgb_to_v) p = len(colors) def make(filename, inp=None): - w = int(256 / p) * p - h = int(256 / p) * p + w = int(128 / p) * p + h = int(128 / p) * p frames = [] @@ -37,7 +37,7 @@ def make(filename, inp=None): if inp is None: image = Image.new("RGBA", (w, h), colors[0]) else: - image = Image.open(inp) + image = Image.open(inp).convert("RGBA") for x in range(image.width): for y in range(image.height): @@ -48,17 +48,17 @@ def make(filename, inp=None): c = colors[v] if inp is not None: existing = image.getpixel((x, y)) - if existing == replace: + if existing[:3] == replace[:3]: image.putpixel((x,y), c) else: image.putpixel((x,y), c) - frames.append(image) + frames.append(image.convert("P")) - frames[0].save(filename, format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) + frames[0].save(filename, mode="P", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) make("dist/images/bg.gif") -make("dist/images/remotecontrol.gif", inp="images/remotecontrol.png") +make("dist/images/remotecontrol.gif", inp="images/remotecontrol-small.png") diff --git a/images/remotecontrol-small.png b/images/remotecontrol-small.png new file mode 100644 index 0000000..fc293d0 Binary files /dev/null and b/images/remotecontrol-small.png differ diff --git a/images/remotecontrol.png b/images/remotecontrol.png index ad9ec97..62d6473 100644 Binary files a/images/remotecontrol.png and b/images/remotecontrol.png differ -- cgit v1.2.1