| @@ -0,0 +1,38 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | """ | |
| 3 | + | lucide2img — fetch an icon from lucide.dev and render it as a square avatar image. | |
| 4 | + | ||
| 5 | + | Examples | |
| 6 | + | -------- | |
| 7 | + | python lucide2img.py camera | |
| 8 | + | python lucide2img.py github -r 1024 --bg "#0d1117" --fg white -f webp | |
| 9 | + | python lucide2img.py heart --bg "#ffe4e6" --fg "#e11d48" --radius 0.5 -o me.png | |
| 10 | + | python lucide2img.py rocket --bg transparent # transparent PNG | |
| 11 | + | ||
| 12 | + | Icon names use lucide's kebab-case (e.g. "arrow-right"); "Arrow Right" and | |
| 13 | + | "arrow_right" are normalized automatically. Browse names at | |
| 14 | + | https://lucide.dev/icons. Note that brand logos (e.g. github) were split out | |
| 15 | + | of Lucide's core set -- use simpleicons2img.py for those. | |
| 16 | + | ||
| 17 | + | Requires: cairosvg + pillow (only for raster output; svg output needs neither). | |
| 18 | + | """ | |
| 19 | + | ||
| 20 | + | from icon2img import IconSource, run | |
| 21 | + | ||
| 22 | + | LUCIDE = IconSource( | |
| 23 | + | key="lucide", | |
| 24 | + | prog_name="lucide2img", | |
| 25 | + | description="Fetch a lucide.dev icon and render it as a square avatar image.", | |
| 26 | + | url_template=( | |
| 27 | + | "https://raw.githubusercontent.com/lucide-icons/lucide/main/icons/{name}.svg" | |
| 28 | + | ), | |
| 29 | + | render_mode="stroke", | |
| 30 | + | browse_url="https://lucide.dev/icons", | |
| 31 | + | icon_arg_help="lucide icon name, e.g. 'camera' or 'arrow-right'", | |
| 32 | + | slug_style="kebab", | |
| 33 | + | default_stroke_width=2.0, | |
| 34 | + | not_found_hint="check the spelling", | |
| 35 | + | ) | |
| 36 | + | ||
| 37 | + | if __name__ == "__main__": | |
| 38 | + | run(LUCIDE) | |
| @@ -0,0 +1,44 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | """ | |
| 3 | + | simpleicons2img — fetch a brand logo from Simple Icons (simpleicons.org) and | |
| 4 | + | render it as a square avatar image. | |
| 5 | + | ||
| 6 | + | Examples | |
| 7 | + | -------- | |
| 8 | + | python simpleicons2img.py python | |
| 9 | + | python simpleicons2img.py github --bg "#0d1117" --fg white -r 1024 -f webp | |
| 10 | + | python simpleicons2img.py spotify --fg "#1DB954" --radius 0.5 -o spotify.png | |
| 11 | + | python simpleicons2img.py x --bg transparent # transparent PNG | |
| 12 | + | ||
| 13 | + | Names use Simple Icons "slugs": lowercase, no spaces (e.g. "Adobe Photoshop" | |
| 14 | + | -> "adobephotoshop", "GitHub" -> "github"). Inputs are lowercased and spaces | |
| 15 | + | stripped automatically; for anything unusual look up the slug at | |
| 16 | + | https://simpleicons.org. | |
| 17 | + | ||
| 18 | + | Note on colors: Simple Icons logos are single-color shapes, so `--fg` sets the | |
| 19 | + | whole logo color (default black). This tool fetches the uncolored source SVGs | |
| 20 | + | directly from the Simple Icons project so recoloring is exact; the | |
| 21 | + | cdn.simpleicons.org endpoint bakes a color in, which would override --fg. | |
| 22 | + | ||
| 23 | + | Requires: cairosvg + pillow (only for raster output; svg output needs neither). | |
| 24 | + | """ | |
| 25 | + | ||
| 26 | + | from icon2img import IconSource, run | |
| 27 | + | ||
| 28 | + | SIMPLE_ICONS = IconSource( | |
| 29 | + | key="simpleicons", | |
| 30 | + | prog_name="simpleicons2img", | |
| 31 | + | description="Fetch a Simple Icons brand logo and render it as a square avatar.", | |
| 32 | + | url_template=( | |
| 33 | + | "https://raw.githubusercontent.com/simple-icons/simple-icons/master/" | |
| 34 | + | "icons/{name}.svg" | |
| 35 | + | ), | |
| 36 | + | render_mode="fill", | |
| 37 | + | browse_url="https://simpleicons.org", | |
| 38 | + | icon_arg_help="Simple Icons slug, e.g. 'python' or 'github'", | |
| 39 | + | slug_style="compact", | |
| 40 | + | not_found_hint="look up the exact slug", | |
| 41 | + | ) | |
| 42 | + | ||
| 43 | + | if __name__ == "__main__": | |
| 44 | + | run(SIMPLE_ICONS) | |
Diff is too large to be shown