{"id":18229730,"url":"https://github.com/vindolin/ninepatch","last_synced_at":"2025-04-03T14:30:31.246Z","repository":{"id":16816778,"uuid":"19575890","full_name":"vindolin/ninepatch","owner":"vindolin","description":"Slice Android style 9-patch images, resize and interactively preview them.","archived":false,"fork":false,"pushed_at":"2023-11-20T15:03:02.000Z","size":338,"stargazers_count":20,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T04:02:44.555Z","etag":null,"topics":[],"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/vindolin.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-05-08T14:12:54.000Z","updated_at":"2024-08-26T07:28:54.000Z","dependencies_parsed_at":"2022-08-25T14:40:37.112Z","dependency_job_id":"50305954-16e8-4245-b66e-aa8ccb5a8fcc","html_url":"https://github.com/vindolin/ninepatch","commit_stats":{"total_commits":143,"total_committers":4,"mean_commits":35.75,"dds":0.0699300699300699,"last_synced_commit":"e1893ae84436c8b0b23dc4fc02f2ae6370945622"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vindolin%2Fninepatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vindolin%2Fninepatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vindolin%2Fninepatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vindolin%2Fninepatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vindolin","download_url":"https://codeload.github.com/vindolin/ninepatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247018239,"owners_count":20869978,"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":[],"created_at":"2024-11-04T10:03:28.095Z","updated_at":"2025-04-03T14:30:30.855Z","avatar_url":"https://github.com/vindolin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Slice Android style 9-patch images, resize and preview them interactively.\n==========================================================================\n[![Python package](https://github.com/vindolin/ninepatch/actions/workflows/python-package.yml/badge.svg)](https://github.com/vindolin/ninepatch/actions/workflows/python-package.yml)\n\nSee \u003chttps://developer.android.com/tools/help/draw9patch.html\u003e for a\n9-patch description.\n\n[![Example image](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/ninepatch_bubble.9.png)](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/ninepatch_bubble.9.png)\n\nInstallation\n============\n\nIf you want to use the interactive viewer read the additional\ninstallation notes under \"Interactive viewer\".\n\n    $ pip install ninepatch\n\nPython usage\n============\n\n``` {.sourceCode .python}\nfrom ninepatch import Ninepatch\nninepatch = Ninepatch('ninepatch_bubble.9.png')\nprint(ninepatch.content_area)  # content_area(left=23, top=20, right=27, bottom=59)\n\n# render the image to a specific size\nscaled_image = ninepatch.render(500, 400) # creates a new PIL image\n\n# render the image so it's content area fits (width, height)\nimage_fit = ninepatch.render_fit(300, 200)\n\n# render the image so it wraps another PIL image\nimage_to_wrap = Image.open('image_to_wrap.png')\nwrapped_image = ninepatch.render_wrap(image_to_wrap)\n```\n\nCommand line usage\n==================\n\nYour image must be a PNG image with a transparent background. The scale\nand fill guide color must be 100% opaque black.\n\nScale and open image in a viewer (PIL image.show()):\n\n    $ ninepatch render ninepatch_bubble.9.png 300 300\n\nSave the scaled image to a new file:\n\n    $ ninepatch render ninepatch_bubble.9.png 300 300 scaled.png\n\n![image](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/ninepatch_bubble_300x300.png)\n\nRender an image so it's content area fits a given width and height\n\n    $ ninepatch fit ninepatch_bubble.9.png 150 150 fit.png\n\n![image](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/fit.png)\n\nRender an image to include another image\n\n    $ ninepatch wrap ninepatch_bubble.9.png image_to_wrap.png wrapped.png\n\n![image](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/wrapped.png)\n\nSlice the 9patch into tiles:\n\n    $ ninepatch slice ninepatch_bubble.9.png ./outputdir\n\n![image](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/slice_export.png)\n\nSlice the 9patch and return a JSON reprensentation of the slicing data:\n\n    $ ninepatch info ninepatch_bubble.9.png\n\n```JSON\n{\n    \"marks\": {\n        \"fill\": {\n            \"x\": [\n                23,\n                231\n            ],\n            \"y\": [\n                20,\n                82\n            ]\n        },\n        \"scale\": {\n            \"x\": [\n                [\n                    49,\n                    49\n                ],\n                [\n                    89,\n                    196\n                ]\n            ],\n            \"y\": [\n                [\n                    42,\n                    63\n                ]\n            ]\n        }\n    },\n    \"size\": [\n        258,\n        141\n    ]\n}\n```\n\nInteractive viewer\n==================\n\n[![ninepatch viewer screenshot](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/ninepatch_viewer_screenshot.png)](https://raw.githubusercontent.com/vindolin/ninepatch/master/src/ninepatch/data/ninepatch_viewer_screenshot.png)\n\nInteractively resize and preview an image in a Tkinter viewer:\n\n    $ ninepatch-viewer ninepatch_bubble.9.png\n\n    or just:\n\n    $ ninepatch-viewer\n\n    without arguments to see the demo image\n\nIf you want to use the viewer then python-pil.imagetk has to be\ninstalled.\n\nOn Ubuntu do:\n\n    $ sudo apt-get install python-pil.imagetk\n\nIf you want to install into a virtualenv, pip needs the following\npackages to compile PIL with Tkinter support:\n\n    $  sudo apt-get install python-tk tk8.6-dev\n\n(You can trigger a recompile of PIL with: \"pip install -I ninepatch\")\n\nChangelog\n=========\n0.2.0\n\n:   -   allow 0-size tiles, now works with pillow \u003e=10.0.0\n\n0.1.22\n\n:   -   fixed error that prevented the ninepatch_viewer to work\n\n0.1.21\n\n:   -   fixed bug in wrap()\n\n0.1.20\n\n:   -   new commands fit and wrap courtesy of Nicolas Laurance\n\n0.1.19\n\n:   -   fixed error in caching\n\n0.1.18\n\n:   -   optional caching for slice() and render()\n\n0.1.17\n\n:   -   new method export\\_slices()\n    -   changed command line parameters (render/slice)\n\n...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvindolin%2Fninepatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvindolin%2Fninepatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvindolin%2Fninepatch/lists"}