Render the SVG at all icon sizes, applying sharpening where configured.
(inkscape: str, work_dir: Path)
| 327 | |
| 328 | |
| 329 | def render_all_sizes(inkscape: str, work_dir: Path) -> list[Image.Image]: |
| 330 | """Render the SVG at all icon sizes, applying sharpening where configured.""" |
| 331 | images = [] |
| 332 | for size in RASTER_SIZES: |
| 333 | png_path = work_dir / f"icon_{size}.png" |
| 334 | if size == 16: |
| 335 | print(f" Using hand-crafted {size}x{size} icon...") |
| 336 | img = make_icon_16() |
| 337 | img.save(png_path) |
| 338 | else: |
| 339 | svg_path = SVG_FOR_SIZE[size] |
| 340 | print(f" Rendering {size}x{size} using {svg_path.name}...") |
| 341 | render_svg(inkscape, svg_path, png_path, size, size) |
| 342 | img = Image.open(png_path).copy() |
| 343 | if size in SHARPEN_AMOUNT: |
| 344 | img = img.filter( |
| 345 | ImageFilter.UnsharpMask( |
| 346 | radius=SHARPEN_RADIUS, percent=SHARPEN_AMOUNT[size], threshold=0 |
| 347 | ) |
| 348 | ) |
| 349 | print(f" Sharpened {size}x{size} (USM {SHARPEN_AMOUNT[size]}%)") |
| 350 | img.save(png_path) |
| 351 | images.append(img) |
| 352 | return images |
| 353 | |
| 354 | |
| 355 | def main(): |
no test coverage detected