diff options
author | davidovski <david@davidovski.xyz> | 2021-11-01 22:53:48 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2021-11-01 22:53:48 +0000 |
commit | 0ec63c97b9009187d7d2d32d5d065a863a6aa323 (patch) | |
tree | 93119162c44a8b26776fa58c5906eab1cf3ef28c /gif.py | |
parent | acd5c8e9bddc25b8759f80dd5282d9a8ac6ea1a6 (diff) |
made images smaller
Diffstat (limited to 'gif.py')
-rw-r--r-- | gif.py | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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") |