{"id":23148292,"url":"https://github.com/sparkfish/glyphcast","last_synced_at":"2025-10-03T14:24:52.832Z","repository":{"id":46861311,"uuid":"203622822","full_name":"sparkfish/glyphcast","owner":"sparkfish","description":"Cairo-inspired dependency-free replacement for casting SVG to PNG or PDF format","archived":false,"fork":false,"pushed_at":"2023-05-23T00:39:13.000Z","size":276,"stargazers_count":4,"open_issues_count":11,"forks_count":1,"subscribers_count":8,"default_branch":"dev","last_synced_at":"2024-05-02T21:49:41.470Z","etag":null,"topics":["cairo","cairsvg","converter","document-conversion","pdf","png","python","resvg","svg","svglib"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sparkfish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-21T16:24:59.000Z","updated_at":"2023-11-01T05:13:41.000Z","dependencies_parsed_at":"2022-08-26T16:10:31.874Z","dependency_job_id":null,"html_url":"https://github.com/sparkfish/glyphcast","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfish%2Fglyphcast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfish%2Fglyphcast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfish%2Fglyphcast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparkfish%2Fglyphcast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparkfish","download_url":"https://codeload.github.com/sparkfish/glyphcast/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230151966,"owners_count":18181327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cairo","cairsvg","converter","document-conversion","pdf","png","python","resvg","svg","svglib"],"created_at":"2024-12-17T17:10:02.979Z","updated_at":"2025-10-03T14:24:47.775Z","avatar_url":"https://github.com/sparkfish.png","language":"Python","readme":"# resvg-py\n\n`resvg-py` provides a Python interface to the [`resvg`](https://github.com/RazrFalcon/resvg/) library, an open-source Rust-based SVG rendering library that can be used to convert SVG images to various other formats such as PNG, PDF, and SVGZ.\n\nThe purpose of `resvg-py` is to provide a convenient way to use `resvg` from within Python code, without the need for external dependencies.  By using `resvg-py`, developers can incorporate SVG rendering functionality directly into their Python applications, making it easier to work with SVG images and to create high-quality, scalable graphics for their projects.\n\nWith `resvg-py`, developers can:\n\n* Load SVG files and render them to various output formats\n* Control the output size, resolution, and quality of the rendered images\n* Work with SVG images directly within their Python code, without the need for external tools or libraries\n\nOverall, `resvg-py` provides a simple and powerful way to work with SVG images in Python, and can be a useful tool for developers who need to work with vector graphics in their projects.\n\n\n# Usage\n\n```python\nfrom pathlib import Path\n\nimport resvg_py\n\noptions = resvg_py.SVGOptions()\nr = resvg_py.Resvg(options)\n\nwith Path(\"resources/examples/svg/octocat.svg\").open(\"r\") as f:\n    rendered = r.render(f.read(), 400, 400)\n\n    with open(\"image.png\", \"wb\") as f:\n        f.write(rendered.as_png())\n```\n\n# Options\n\nThe `Options` class within the `resvg-py` library is responsible for providing customization and configuration options for rendering SVG files.  This class contains properties that define different aspects of the rendering process, such as dimensions, background color, and language. The following documentation will cover each property within the `Options` class, their purpose, and the allowed range of values.\n\n## Properties\n\n|Name|Purpose|Type|Allowed Values|Example|\n|:----|:----|:----|:----|:----|\n|width|Defines the width of the output image in pixels|Integer|Positive integers (1 and above)|`options.width = 300`|\n|height|Defines the height of the output image in pixels|Integer|Positive integers (1 and above)|`options.height = 200`|\n|fit_to|Controls how the SVG should be scaled to fit the output|String or Tuple|\"original\", (\"width\", value), (\"height\", value), (\"zoom\", factor)|`options.fit_to = (\"width\", 300)`|\n|background|Sets the background color of the output image|String or None|6 or 8-digit hex color codes or `None`|`options.background = \"#FFAABB\"`|\n|dpi|Specifies the DPI value used for rendering|Float|Positive float values (greater than 0)|`options.dpi = 96.0`|\n|languages|Sets the list of languages for `systemLanguage` attribute|List of strings|Valid [BCP 47](https://tools.ietf.org/html/bcp47) language codes|`options.languages = [\"en\", \"fr\", \"es\"]`|\n|shape_rendering|Controls the rendering mode for shapes|String|optimizeSpeed\", \"crispEdges\", \"geometricPrecision|`options.shape_rendering = \"optimizeSpeed\"`|\n|text_rendering|Controls the rendering mode for text|String|optimizeSpeed\", \"optimizeLegibility\", \"geometricPrecision|`options.text_rendering = \"optimizeLegibility\"`|\n|image_rendering|Controls the rendering mode for images|String|optimizeQuality\", \"optimizeSpeed\", \"pixelated|`options.image_rendering = \"optimizeQuality\"`|\n|skip_system_fonts|Skip loading system fonts when rendering text|Boolean|`True` or `False`|`options.skip_system_fonts = True`|\n|font_size|Specifies the default font size for text elements|Float|Positive float values (greater than 0)|`options.font_size = 14.0`|\n|font_family|Specifies the default font family for text elements|String|Valid font family names|`options.font_family = \"Arial\"`|\n|font_path|Path to a custom font file|String|Valid file path|`options.font_path = \"path/to/font.ttf\"`|\n\n\n## Example Usage\n\n```python\nfrom resvg import Options, render_from_file\n\noptions = Options()\noptions.width = 300\noptions.height = 200\noptions.background = \"#FFAABB\"\noptions.dpi = 96.0\noptions.languages = [\"en\", \"fr\", \"es\"]\noptions.shape_rendering = \"optimizeSpeed\"\noptions.text_rendering = \"optimizeLegibility\"\noptions.image_rendering = \"optimizeQuality\"\n\noutput_image = render_from_file(\"input.svg\", options)\n```\n\n\n# How To Build\n\n## Install Rust, Set up Python Dev Requirements\n\n**Windows**\n\n```sh\nchoco install rust\n```\n\n**Set up Virtual Environemt**\n\n```sh\npython -m venv venv\n.\\venv\\Scripts\\Activate.bat\n```\n\n**Install Maturin and Pytest**\n\n```sh\npip install -r requirements-dev.txt\n```\n\n## Build Python Wheel\n\n```sh\nmaturin develop\n```\n\n## Run Tests\n\n```sh\npytest\n```\n\nTo update the snapshots:\n\n```sh\npytest --snapshot-update\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparkfish%2Fglyphcast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparkfish%2Fglyphcast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparkfish%2Fglyphcast/lists"}