made images smaller
This commit is contained in:
parent
1a636fa9c0
commit
712dc5f7b8
14
gif.py
14
gif.py
|
@ -28,8 +28,8 @@ sorted(colors, key=rgb_to_v)
|
||||||
p = len(colors)
|
p = len(colors)
|
||||||
|
|
||||||
def make(filename, inp=None):
|
def make(filename, inp=None):
|
||||||
w = int(256 / p) * p
|
w = int(128 / p) * p
|
||||||
h = int(256 / p) * p
|
h = int(128 / p) * p
|
||||||
|
|
||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ def make(filename, inp=None):
|
||||||
if inp is None:
|
if inp is None:
|
||||||
image = Image.new("RGBA", (w, h), colors[0])
|
image = Image.new("RGBA", (w, h), colors[0])
|
||||||
else:
|
else:
|
||||||
image = Image.open(inp)
|
image = Image.open(inp).convert("RGBA")
|
||||||
|
|
||||||
for x in range(image.width):
|
for x in range(image.width):
|
||||||
for y in range(image.height):
|
for y in range(image.height):
|
||||||
|
@ -48,17 +48,17 @@ def make(filename, inp=None):
|
||||||
c = colors[v]
|
c = colors[v]
|
||||||
if inp is not None:
|
if inp is not None:
|
||||||
existing = image.getpixel((x, y))
|
existing = image.getpixel((x, y))
|
||||||
if existing == replace:
|
if existing[:3] == replace[:3]:
|
||||||
image.putpixel((x,y), c)
|
image.putpixel((x,y), c)
|
||||||
else:
|
else:
|
||||||
image.putpixel((x,y), c)
|
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/bg.gif")
|
||||||
make("dist/images/remotecontrol.gif", inp="images/remotecontrol.png")
|
make("dist/images/remotecontrol.gif", inp="images/remotecontrol-small.png")
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue