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:
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 directory. A very basic example of XML code that displays the text "Hello World!" in an image is:
<?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
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:
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 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 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.
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 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 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.
Metadata
Release files for layout-image 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| layout-image-0.2.0.tar.gz | 8.9 kB | Without provenance | Details for layout-image-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| layout_image-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for layout_image-0.2.0-py3-none-any.whl |
Total release size: 20.4 kB
Release files / layout-image-0.2.0.tar.gz
| Download URL | layout-image-0.2.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7454a86a86102894db5cd096ef6ab2d6f6266a85fcd488bd99e87a0193e12fc5
|
|
BLAKE2b-256 checksum How to use checksums |
d4fcae90b7967d8a194653035deabfeeedb4a5b64dccb3672303e7f71a52ed36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Release files / layout_image-0.2.0-py3-none-any.whl
| Download URL | layout_image-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bf7be335801538322a96b6c96bd41519f4e86d28c6315516c83ef8740dd72ca
|
|
BLAKE2b-256 checksum How to use checksums |
b45a9d5d75b95d98c190aef06b55713369c9dd663358230cc877594ec82d2ca2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Security for layout-image 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.