layout-image


Namelayout-image JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA package for creating basic images with XML layouts
upload_time2024-04-02 17:52:43
maintainerNone
docs_urlNone
authorDirck van den Ende
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Dirck van den Ende Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords image layout xml design
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# `layout-image`: A package for generating simple text-based images

A python package for creating basic images with XML layouts.

## Installation

The package can be installed using the following command, which copies the GitHub repository:
```sh
pip install git+https://github.com/dirckvdende/layout-image.git
```

## Basic Example

Several examples of layouts that can be rendered can be found in the [examples](./examples/) directory. A very basic example of XML code that displays the text "Hello World!" in an image is:
```xml
<?xml version="1.0"?>
<image>
    <text>Hello World!</text>
</image>
```
Every layout image has `<image>` as the root element. Inside it can be some layout of elements. Only `<text>` elements can contain text that will be rendered to the screen. This example can be converted to an image using
```sh
python -m layoutimg ./examples/hello-world.xml
```
This will produce a PNG image that has the same path as the XML file, with `.png` appended to it. Alternatively the PNG can be generated using Python code:
```py
from layoutimg import LayoutImage

# Open the example file and read contents
with open("./examples/hello-world.xml", "r") as f:
    text = f.read()
# Create a layout image from the source file text
image = LayoutImage(text)
# Generate image data
image.generate()
# Save image to PNG file
image.save("./examples/hello-world.xml.png")
```

## Syntax

To display multiple lines of text, the `<row>` tag can be used as follows:
```xml
<?xml version="1.0"?>
<image>
    <row><text>Foo</text></row>
    <row><text>Bar</text></row>
</image>
```
Similarly, the `<col>` tag can be used to display elements next to each other. Rows and columns can be nested to form a table:
```xml
<?xml version="1.0"?>
<image>
    <col>
        <row><text>Fizz</text></row>
        <row><text>Buzz</text></row>
    </col>
    <col>
        <row><text>Bazz</text></row>
        <row><text>Fuzz</text></row>
    </col>
</image>
```
A description of every tag can be found at [Element Tags](./docs/tags.md).

### Attributes

That style and modify the elements, attributes can be used. For example, a row or column can be given a background color as follows:
```xml
<?xml version="1.0"?>
<image>
    <row background-color="blue"><text>Foo</text></row>
</image>
```
We can also change the width of the row, and display the text in the center:
```xml
<?xml version="1.0"?>
<image>
    <row background-color="blue" width="500"><text text-align="center">Foo</text></row>
</image>
```
A complete list of attributes with possible values can be found at [Element Attributes](./docs/attributes.md).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "layout-image",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "image, layout, XML, design",
    "author": "Dirck van den Ende",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d4/fc/ae90b7967d8a194653035deabfeeedb4a5b64dccb3672303e7f71a52ed36/layout-image-0.2.0.tar.gz",
    "platform": null,
    "description": "\n# `layout-image`: A package for generating simple text-based images\n\nA python package for creating basic images with XML layouts.\n\n## Installation\n\nThe package can be installed using the following command, which copies the GitHub repository:\n```sh\npip install git+https://github.com/dirckvdende/layout-image.git\n```\n\n## Basic Example\n\nSeveral examples of layouts that can be rendered can be found in the [examples](./examples/) directory. A very basic example of XML code that displays the text \"Hello World!\" in an image is:\n```xml\n<?xml version=\"1.0\"?>\n<image>\n    <text>Hello World!</text>\n</image>\n```\nEvery layout image has `<image>` as the root element. Inside it can be some layout of elements. Only `<text>` elements can contain text that will be rendered to the screen. This example can be converted to an image using\n```sh\npython -m layoutimg ./examples/hello-world.xml\n```\nThis will produce a PNG image that has the same path as the XML file, with `.png` appended to it. Alternatively the PNG can be generated using Python code:\n```py\nfrom layoutimg import LayoutImage\n\n# Open the example file and read contents\nwith open(\"./examples/hello-world.xml\", \"r\") as f:\n    text = f.read()\n# Create a layout image from the source file text\nimage = LayoutImage(text)\n# Generate image data\nimage.generate()\n# Save image to PNG file\nimage.save(\"./examples/hello-world.xml.png\")\n```\n\n## Syntax\n\nTo display multiple lines of text, the `<row>` tag can be used as follows:\n```xml\n<?xml version=\"1.0\"?>\n<image>\n    <row><text>Foo</text></row>\n    <row><text>Bar</text></row>\n</image>\n```\nSimilarly, the `<col>` tag can be used to display elements next to each other. Rows and columns can be nested to form a table:\n```xml\n<?xml version=\"1.0\"?>\n<image>\n    <col>\n        <row><text>Fizz</text></row>\n        <row><text>Buzz</text></row>\n    </col>\n    <col>\n        <row><text>Bazz</text></row>\n        <row><text>Fuzz</text></row>\n    </col>\n</image>\n```\nA description of every tag can be found at [Element Tags](./docs/tags.md).\n\n### Attributes\n\nThat style and modify the elements, attributes can be used. For example, a row or column can be given a background color as follows:\n```xml\n<?xml version=\"1.0\"?>\n<image>\n    <row background-color=\"blue\"><text>Foo</text></row>\n</image>\n```\nWe can also change the width of the row, and display the text in the center:\n```xml\n<?xml version=\"1.0\"?>\n<image>\n    <row background-color=\"blue\" width=\"500\"><text text-align=\"center\">Foo</text></row>\n</image>\n```\nA complete list of attributes with possible values can be found at [Element Attributes](./docs/attributes.md).\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Dirck van den Ende  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A package for creating basic images with XML layouts",
    "version": "0.2.0",
    "project_urls": {
        "repository": "https://github.com/dirckvdende/layout-image"
    },
    "split_keywords": [
        "image",
        " layout",
        " xml",
        " design"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b45a9d5d75b95d98c190aef06b55713369c9dd663358230cc877594ec82d2ca2",
                "md5": "fe0f3f0969af3388049c3cb51364aff8",
                "sha256": "0bf7be335801538322a96b6c96bd41519f4e86d28c6315516c83ef8740dd72ca"
            },
            "downloads": -1,
            "filename": "layout_image-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe0f3f0969af3388049c3cb51364aff8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11448,
            "upload_time": "2024-04-02T17:52:41",
            "upload_time_iso_8601": "2024-04-02T17:52:41.967301Z",
            "url": "https://files.pythonhosted.org/packages/b4/5a/9d5d75b95d98c190aef06b55713369c9dd663358230cc877594ec82d2ca2/layout_image-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d4fcae90b7967d8a194653035deabfeeedb4a5b64dccb3672303e7f71a52ed36",
                "md5": "380cad463c5ad6dc25bd5a0085cc7cbf",
                "sha256": "7454a86a86102894db5cd096ef6ab2d6f6266a85fcd488bd99e87a0193e12fc5"
            },
            "downloads": -1,
            "filename": "layout-image-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "380cad463c5ad6dc25bd5a0085cc7cbf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8942,
            "upload_time": "2024-04-02T17:52:43",
            "upload_time_iso_8601": "2024-04-02T17:52:43.845818Z",
            "url": "https://files.pythonhosted.org/packages/d4/fc/ae90b7967d8a194653035deabfeeedb4a5b64dccb3672303e7f71a52ed36/layout-image-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-02 17:52:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dirckvdende",
    "github_project": "layout-image",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "layout-image"
}
        
Elapsed time: 0.53819s