Removed old and added new icons for each color in designate directories.
3
assets/icons/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from .icons import colors, generate_pngs
|
||||
63
assets/icons/icons.py
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import cairosvg
|
||||
import codecs
|
||||
import discord
|
||||
import inspect
|
||||
import pathlib
|
||||
import PIL
|
||||
import tempfile
|
||||
|
||||
# I need a list of all colors that the Discord library offers, and I can't seem
|
||||
# to find a good one, so I'm going to just create one here
|
||||
colors = ['ash_embed', 'ash_theme', 'blue', 'blurple', 'brand_green',
|
||||
'brand_red', 'dark_blue', 'dark_embed', 'dark_gold', 'dark_gray',
|
||||
'dark_green', 'dark_grey', 'dark_magenta', 'dark_orange', 'dark_purple',
|
||||
'dark_red', 'dark_teal', 'dark_theme', 'darker_gray', 'darker_grey',
|
||||
'default', 'fuchsia', 'gold', 'green', 'greyple', 'light_embed',
|
||||
'light_gray', 'light_grey', 'light_theme', 'lighter_gray',
|
||||
'lighter_grey', 'magenta', 'og_blurple', 'onyx_embed', 'onyx_theme',
|
||||
'orange', 'pink', 'purple', 'red', 'teal', 'yellow']
|
||||
|
||||
def generate_pngs(svg_path: pathlib.Path, png_path: pathlib.Path):
|
||||
"""Generate icons for embed messages.
|
||||
|
||||
This method takes SVG files, changes their colors, and converts them into
|
||||
PNG files for use in Discord message embeds. Since uploading the image
|
||||
itself to the Discord message isn't an option, we are going to create a
|
||||
designated directory for the icons, and use the public URL for it to point
|
||||
Discord to the proper icon.
|
||||
|
||||
Params:
|
||||
svg_path (pathlib.Path): The path to the SVG files to be converted.
|
||||
png_path (pathlib.Path): The path to store the resultant PNG files.
|
||||
"""
|
||||
# Convert to each Discord color
|
||||
for color_name in colors:
|
||||
color_dir = png_path / color_name
|
||||
color_dir.mkdir(parents=True, exist_ok=True)
|
||||
color_hex = str(getattr(discord.Colour, color_name)())
|
||||
|
||||
# Open each SVG in the directory
|
||||
for svg_file in svg_path.glob("*.svg"):
|
||||
with codecs.open(svg_file, "r", encoding="utf-8") as f:
|
||||
svg_data = f.read()
|
||||
|
||||
# Convert the SVG elements to the correct new color
|
||||
svg_data = svg_data.replace("#000000", color_hex)
|
||||
|
||||
# If we just save the new PNG, the icon will completely fill the
|
||||
# image, but we're going to use it in areas of Discord messages
|
||||
# where they are rendered in circles, so we're going to add margins
|
||||
# on each side so that the icon doesn't get cut off
|
||||
with tempfile.NamedTemporaryFile(delete=True) as temp:
|
||||
cairosvg.svg2png(
|
||||
bytestring=svg_data.encode("utf-8"), write_to=temp.name)
|
||||
# Resize to add border
|
||||
img = PIL.Image.open(temp.name).convert("RGBA")
|
||||
img = PIL.ImageOps.expand(img, border=100, fill=(0, 0, 0, 0))
|
||||
img.resize((300, 300), PIL.Image.LANCZOS)
|
||||
|
||||
# Save to actual PNG file
|
||||
img.save(color_dir / f"{svg_file.stem}.png", format="PNG")
|
||||
print("new file:", color_dir / f"{svg_file.stem}.png")
|
||||
BIN
assets/icons/png/ash_embed/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/ash_embed/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
assets/icons/png/ash_embed/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/ash_embed/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/ash_embed/line-3.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
assets/icons/png/ash_embed/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/ash_embed/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/ash_embed/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/ash_embed/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/ash_embed/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/ash_embed/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/icons/png/ash_embed/music-note.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
assets/icons/png/ash_embed/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/ash_embed/search.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/ash_theme/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/ash_theme/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
assets/icons/png/ash_theme/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/ash_theme/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/ash_theme/line-3.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
assets/icons/png/ash_theme/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/ash_theme/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/ash_theme/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/ash_theme/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/ash_theme/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/ash_theme/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/icons/png/ash_theme/music-note.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
assets/icons/png/ash_theme/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/ash_theme/search.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
assets/icons/png/blue/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/blue/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/blue/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/blue/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/blue/line-3.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/blue/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/blue/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/blue/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/blue/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/blue/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/blue/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
assets/icons/png/blue/music-note.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/icons/png/blue/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/blue/search.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/blurple/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/blurple/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/blurple/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/blurple/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/blurple/line-3.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
assets/icons/png/blurple/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/blurple/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/blurple/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/blurple/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/blurple/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/blurple/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/icons/png/blurple/music-note.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/icons/png/blurple/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/blurple/search.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/brand_green/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/brand_green/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/brand_green/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/brand_green/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/brand_green/line-3.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
assets/icons/png/brand_green/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/brand_green/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/brand_green/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/brand_green/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/brand_green/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/brand_green/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/icons/png/brand_green/music-note.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/icons/png/brand_green/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/brand_green/search.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/brand_red/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/brand_red/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/brand_red/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/brand_red/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/brand_red/line-3.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
assets/icons/png/brand_red/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/brand_red/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/brand_red/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/brand_red/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/brand_red/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/brand_red/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/icons/png/brand_red/music-note.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/icons/png/brand_red/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/brand_red/search.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/dark_blue/arrow-2-rectangle-path.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/dark_blue/arrow-cw.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/icons/png/dark_blue/dots-3-horizontal.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/dark_blue/headphones.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
assets/icons/png/dark_blue/line-3.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/dark_blue/list-bullet.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/icons/png/dark_blue/media-backward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/dark_blue/media-forward.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/icons/png/dark_blue/media-pause.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/icons/png/dark_blue/media-play.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/icons/png/dark_blue/media-stop.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/icons/png/dark_blue/music-note.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/icons/png/dark_blue/plus.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
assets/icons/png/dark_blue/search.png
Normal file
|
After Width: | Height: | Size: 30 KiB |