Name | faker-graphics JSON |
Version |
0.3.0
JSON |
| download |
home_page | |
Summary | Provider for the Faker package to generate placeholder images and more. |
upload_time | 2023-09-19 11:02:32 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | |
keywords |
faker
factory-boy
placeholder
images
colors
cairo
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# faker-graphics
[![CI](https://github.com/fdemmer/faker-graphics/actions/workflows/test.yml/badge.svg)](https://github.com/fdemmer/faker-graphics/actions/workflows/test.yml)
[![Version](https://img.shields.io/pypi/v/faker-graphics.svg)](https://pypi.org/project/faker-graphics/)
[![Python](https://img.shields.io/pypi/pyversions/faker-graphics.svg)](https://pypi.org/project/faker-graphics/)
[![License](https://img.shields.io/pypi/l/faker-graphics.svg)](https://pypi.org/project/faker-graphics/)
Provider for [Faker](https://pypi.org/project/Faker/) to generate placeholder images with [cairo](https://www.cairographics.org).
- Includes a random color generator forked from the
[Python port](https://github.com/kevinwuhoo/randomcolor-py) of
[randomColor.js](https://github.com/davidmerfield/randomColor)
- Provides a simple CLI to generate image files or just colors in the terminal
- Generated images show size, aspect ratio and a simple geometry
## Installation
```bash
$ pip install faker-graphics
```
## Usage with Faker and/or Factory-Boy
### Register the provider with Faker
The faker-graphics provider will reuse Faker's random instance.
```python
from faker import Faker
from faker_graphics import Provider
fake = Faker()
fake.add_provider(Provider)
```
### Alternatively register the provider with Faker via Factory-Boy
```python
import factory
from faker_graphics import Provider
factory.Faker.add_provider(Provider)
```
### Using the "placeholder_image" fake
After registration the "placeholder_image" fake is available.
It returns a PNG image as bytes.
```python
from faker import Faker
fake = Faker()
data = fake.placeholder_image()
assert data[:6] == b'\x89PNG\r\n'
```
`placeholder_image()` accepts the following optional arguments:
- `width`: image size in pixels, default: 256
- `height`: image size in pixels, default: 256
- `hue`: influence the color randomizer, e.g. a hue name like "green", "blue", "pink" (see `fgr colormap` command below) or a number in a 360° spectrum, default: `None` results in random color
- `luminosity`: "random", "bright", "dark", "light", default: `Luminosity.light`
### Usage with Factory-Boy/Django
```python
import factory
class ModelWithImageFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'models.ModelWithImage'
image = factory.django.FileField(
filename='mock_image.png',
data=factory.Faker(
'placeholder_image',
width=640,
height=320,
hue='green',
luminosity='dark',
),
)
```
## CLI Usage
The CLI provides sub commands for various tasks.
```bash
$ fgr --help
Usage: fgr [OPTIONS] COMMAND [ARGS]...
faker_graphics commandline interface.
Options:
-v, --verbose Increase verbosity.
--help Show this message and exit.
Commands:
color Show random colors in your terminal.
colormap Show colormap used by random color generator as JSON.
image Generate a placeholder image with random hue.
```
All subcommands provide their own `--help` messages!
### Generate an image via CLI
Create image files or write to stdout using `-` as `OUTPUT`.
```bash
$ fgr image sample.png green --size 640 320 --luminosity dark
```
![Example Image](https://raw.githubusercontent.com/fdemmer/faker-graphics/main/docs/img/example.png)
### Show colormap
The `colormap` command returns the whole colormap as JSON; you could use `jq` to extract the known hue names.
```bash
$ fgr colormap | jq "keys_unsorted"
[
"monochrome",
"grey",
"red",
"orange",
"yellow",
"green",
"cyan",
"blue",
"purple",
"magenta",
"pink"
]
```
### Generate random colors
Generate one or multiple random colors. Colors are returned as HSV/B values and shown as background color if your terminal supports it.
```bash
$ fgr color pink --count 3 --luminosity light --sorted
hsv(328, 30, 98) rgb(249, 174, 214) #f9aed6
hsv(334, 55, 97) rgb(247, 111, 170) #f76faa
hsv(344, 26, 100) rgb(255, 188, 206) #ffbcce
```
Raw data
{
"_id": null,
"home_page": "",
"name": "faker-graphics",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "faker,factory-boy,placeholder,images,colors,cairo",
"author": "",
"author_email": "Florian Demmer <fdemmer@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/94/6d/7a8f74d2ce8262d60e4abe6114cadefbd4cdce0b82aae53c6bbf6d4783b9/faker_graphics-0.3.0.tar.gz",
"platform": null,
"description": "# faker-graphics\n\n[![CI](https://github.com/fdemmer/faker-graphics/actions/workflows/test.yml/badge.svg)](https://github.com/fdemmer/faker-graphics/actions/workflows/test.yml)\n[![Version](https://img.shields.io/pypi/v/faker-graphics.svg)](https://pypi.org/project/faker-graphics/)\n[![Python](https://img.shields.io/pypi/pyversions/faker-graphics.svg)](https://pypi.org/project/faker-graphics/)\n[![License](https://img.shields.io/pypi/l/faker-graphics.svg)](https://pypi.org/project/faker-graphics/)\n\nProvider for [Faker](https://pypi.org/project/Faker/) to generate placeholder images with [cairo](https://www.cairographics.org).\n\n- Includes a random color generator forked from the\n [Python port](https://github.com/kevinwuhoo/randomcolor-py) of\n [randomColor.js](https://github.com/davidmerfield/randomColor)\n- Provides a simple CLI to generate image files or just colors in the terminal\n- Generated images show size, aspect ratio and a simple geometry\n\n## Installation\n\n```bash\n$ pip install faker-graphics\n```\n\n## Usage with Faker and/or Factory-Boy\n\n### Register the provider with Faker\n\nThe faker-graphics provider will reuse Faker's random instance.\n\n```python\nfrom faker import Faker\nfrom faker_graphics import Provider\n\nfake = Faker()\nfake.add_provider(Provider)\n```\n\n### Alternatively register the provider with Faker via Factory-Boy\n\n```python\nimport factory\nfrom faker_graphics import Provider\n\nfactory.Faker.add_provider(Provider)\n```\n\n### Using the \"placeholder_image\" fake\n\nAfter registration the \"placeholder_image\" fake is available.\nIt returns a PNG image as bytes.\n\n```python\nfrom faker import Faker\n\nfake = Faker()\ndata = fake.placeholder_image()\nassert data[:6] == b'\\x89PNG\\r\\n'\n```\n\n`placeholder_image()` accepts the following optional arguments:\n\n- `width`: image size in pixels, default: 256\n- `height`: image size in pixels, default: 256\n- `hue`: influence the color randomizer, e.g. a hue name like \"green\", \"blue\", \"pink\" (see `fgr colormap` command below) or a number in a 360\u00b0 spectrum, default: `None` results in random color\n- `luminosity`: \"random\", \"bright\", \"dark\", \"light\", default: `Luminosity.light`\n\n### Usage with Factory-Boy/Django\n\n```python\nimport factory\n\nclass ModelWithImageFactory(factory.django.DjangoModelFactory):\n class Meta:\n model = 'models.ModelWithImage'\n\n image = factory.django.FileField(\n filename='mock_image.png',\n data=factory.Faker(\n 'placeholder_image',\n width=640,\n height=320,\n hue='green',\n luminosity='dark',\n ),\n )\n```\n\n## CLI Usage\n\nThe CLI provides sub commands for various tasks.\n\n```bash\n$ fgr --help\nUsage: fgr [OPTIONS] COMMAND [ARGS]...\n\n faker_graphics commandline interface.\n\nOptions:\n -v, --verbose Increase verbosity.\n --help Show this message and exit.\n\nCommands:\n color Show random colors in your terminal.\n colormap Show colormap used by random color generator as JSON.\n image Generate a placeholder image with random hue.\n```\n\nAll subcommands provide their own `--help` messages!\n\n### Generate an image via CLI\n\nCreate image files or write to stdout using `-` as `OUTPUT`.\n\n```bash\n$ fgr image sample.png green --size 640 320 --luminosity dark\n```\n\n![Example Image](https://raw.githubusercontent.com/fdemmer/faker-graphics/main/docs/img/example.png)\n\n### Show colormap\n\nThe `colormap` command returns the whole colormap as JSON; you could use `jq` to extract the known hue names.\n\n```bash\n$ fgr colormap | jq \"keys_unsorted\"\n[\n \"monochrome\",\n \"grey\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"cyan\",\n \"blue\",\n \"purple\",\n \"magenta\",\n \"pink\"\n]\n```\n\n### Generate random colors\n\nGenerate one or multiple random colors. Colors are returned as HSV/B values and shown as background color if your terminal supports it.\n\n```bash\n$ fgr color pink --count 3 --luminosity light --sorted\n hsv(328, 30, 98) rgb(249, 174, 214) #f9aed6\n hsv(334, 55, 97) rgb(247, 111, 170) #f76faa\n hsv(344, 26, 100) rgb(255, 188, 206) #ffbcce\n```\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Provider for the Faker package to generate placeholder images and more.",
"version": "0.3.0",
"project_urls": {
"Changelog": "https://github.com/fdemmer/faker-graphics/releases",
"Homepage": "https://github.com/fdemmer/faker-graphics",
"Repository": "https://github.com/fdemmer/faker-graphics.git"
},
"split_keywords": [
"faker",
"factory-boy",
"placeholder",
"images",
"colors",
"cairo"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7f2638b9310ec3abe76475d72ff758cf3070a4c9e5b62e3d574fd08bb74c75ea",
"md5": "f343696fc6e197aa31f1a741d6cece13",
"sha256": "ba33ca38654739ec51558fae3a20901fa149e9fc110a31147de2b02e84450f4e"
},
"downloads": -1,
"filename": "faker_graphics-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f343696fc6e197aa31f1a741d6cece13",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11077,
"upload_time": "2023-09-19T11:02:30",
"upload_time_iso_8601": "2023-09-19T11:02:30.903407Z",
"url": "https://files.pythonhosted.org/packages/7f/26/38b9310ec3abe76475d72ff758cf3070a4c9e5b62e3d574fd08bb74c75ea/faker_graphics-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "946d7a8f74d2ce8262d60e4abe6114cadefbd4cdce0b82aae53c6bbf6d4783b9",
"md5": "b493c578c75cbcdc89ab6fb5e1448929",
"sha256": "e966ffe373ee81f98d137de96050eedc957f5316e226d19edc4787c05e2dec4e"
},
"downloads": -1,
"filename": "faker_graphics-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "b493c578c75cbcdc89ab6fb5e1448929",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12045,
"upload_time": "2023-09-19T11:02:32",
"upload_time_iso_8601": "2023-09-19T11:02:32.029193Z",
"url": "https://files.pythonhosted.org/packages/94/6d/7a8f74d2ce8262d60e4abe6114cadefbd4cdce0b82aae53c6bbf6d4783b9/faker_graphics-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-19 11:02:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fdemmer",
"github_project": "faker-graphics",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "faker-graphics"
}