Compare commits
6 Commits
v0.0.4
...
70d0279cb9
Author | SHA1 | Date | |
---|---|---|---|
70d0279cb9
|
|||
62ef828e4b
|
|||
ce752d30e2
|
|||
1365273ff0
|
|||
2f4f61ef82
|
|||
7df479c59e
|
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
- master
|
||||
tags-ignore:
|
||||
- v*
|
||||
pull_request:
|
||||
|
33
.vscode/tasks.json
vendored
Normal file
33
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build",
|
||||
"type": "shell",
|
||||
"linux": {
|
||||
"command": "./.venv/bin/python -m build"
|
||||
},
|
||||
"windows": {
|
||||
"command": ".\\.venv\\Scripts\\python.exe -m build"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Publish",
|
||||
"type": "shell",
|
||||
"linux": {
|
||||
"command": "./.venv/bin/python -m twine upload --repository gitea ./dist/*"
|
||||
},
|
||||
"windows": {
|
||||
"command": ".\\.venv\\Scripts\\python.exe -m twine upload --repository gitea ./dist/*"
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
54
README.md
54
README.md
@@ -11,57 +11,23 @@ Mastodon [huebot](https://botsin.space/@huebot).
|
||||
|
||||
## Installation
|
||||
|
||||
### Nix
|
||||
|
||||
This project is a [Nix Flake](https://nixos.wiki/wiki/Flakes). If you
|
||||
have a recent version of the [Nix package manager](https://nixos.org/)
|
||||
installed and Flakes are enabled, run huepaper like this:
|
||||
|
||||
``` example
|
||||
nix run github:Deleh/huepaper
|
||||
```
|
||||
|
||||
Parameters can be passed by appending a double-dash:
|
||||
|
||||
``` example
|
||||
nix run github:Deleh/huepaper -- -hue 0.5 --color lightblue
|
||||
```
|
||||
|
||||
Global installation can be done by including this flake in your flaked
|
||||
NixOS configuration as always :)
|
||||
|
||||
### Legacy
|
||||
|
||||
Execute the following steps to run huepaper:
|
||||
|
||||
``` example
|
||||
pip install -r requirements.txt
|
||||
./huepaper.py
|
||||
```
|
||||
|
||||
```{=org}
|
||||
#+end_example
|
||||
```
|
||||
|
||||
To install it in your Python environment run:
|
||||
|
||||
``` example
|
||||
python setup.py install
|
||||
```shell
|
||||
pip install --index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple/ huepaper
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```example
|
||||
usage: huepaper [-h] [-s SIZE] [-c COLOR] [-np] [-o OUTPUT] [-l [LINES]] [-lb [LINES_BRIGHT]] [-ld [LINES_DARK]] [-P [PIXELATE]] [-e EMBLEM] [-hue HUE] [-smin SMIN] [-smax SMAX] [-lmin LMIN] [-lmax LMAX]
|
||||
usage: huepaper [-h] [--width WIDTH] [--height HEIGHT] [-c COLOR] [-np] [-o OUTPUT] [-l [LINES]] [-lb [LINES_BRIGHT]] [-ld [LINES_DARK]] [-p [PIXELATE]] [-e EMBLEM] [-hue HUE] [-smin SMIN] [-smax SMAX] [-lmin LMIN] [-lmax LMAX]
|
||||
|
||||
Create wallpapers based on color hues.
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-s SIZE, --size SIZE size of huepaper in the form WIDTHxHEIGHT (default: 1920x1080)
|
||||
--width WIDTH width of the image (default: 1920)
|
||||
--height HEIGHT height of the image (default: 1080)
|
||||
-c COLOR, --color COLOR
|
||||
base color from which the huepaper is generated (default: random color)
|
||||
-np, --no-preview don't preview the huepaper
|
||||
-o OUTPUT, --output OUTPUT
|
||||
filepath where the huepaper will be saved
|
||||
-l [LINES], --lines [LINES]
|
||||
@@ -81,6 +47,14 @@ optional arguments:
|
||||
-lmax LMAX maximum luminance for colors in range [0, 1] (default: 0.9)
|
||||
```
|
||||
|
||||
...or as a Python module
|
||||
|
||||
```python
|
||||
from huepaper import generate
|
||||
|
||||
image = generate(width=500, height=500, hue_max=1.0, lum_min=0.3, lum_max=0.6, sat_min=0.8, sat_max=1.0)
|
||||
```
|
||||
|
||||
All image operations are called in order of the help file. E.g. pixelate
|
||||
(`-p`) is called after adding lines (`-l`).
|
||||
|
||||
@@ -141,7 +115,7 @@ huepaper -hue 1.0 -lmin 0.3 -lmax 0.6 -smin 0.8 -smax 1.0
|
||||

|
||||
|
||||
``` example
|
||||
huepaper -hue 0.3 -lmin 0.5 -lmax 0.5 -l 0.5 -P 64x36
|
||||
huepaper -hue 0.3 -lmin 0.5 -lmax 0.5 -l 0.5 -p 64x36
|
||||
```
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
BIN
tests/assets/emblem.png
Normal file
BIN
tests/assets/emblem.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
@@ -1,36 +0,0 @@
|
||||
from os import remove
|
||||
from pathlib import Path
|
||||
|
||||
from PIL.Image import Image
|
||||
|
||||
from huepaper import generate
|
||||
from huepaper.utils import save_image
|
||||
|
||||
|
||||
def test_generation():
|
||||
image = generate(
|
||||
width=500,
|
||||
height=500,
|
||||
hue_max=1.0,
|
||||
lum_min=0.3,
|
||||
lum_max=0.6,
|
||||
sat_min=0.8,
|
||||
sat_max=1.0,
|
||||
)
|
||||
assert isinstance(image, Image)
|
||||
|
||||
|
||||
def test_saving():
|
||||
image = generate(
|
||||
500,
|
||||
500,
|
||||
hue_max=1.0,
|
||||
lum_min=0.3,
|
||||
lum_max=0.6,
|
||||
sat_min=0.8,
|
||||
sat_max=1.0,
|
||||
lines=0.0,
|
||||
)
|
||||
save_image(image, Path("tests/image.jpg"))
|
||||
assert Path("tests/image.jpg").exists()
|
||||
remove(Path("tests/image.jpg"))
|
84
tests/test_generator.py
Normal file
84
tests/test_generator.py
Normal file
@@ -0,0 +1,84 @@
|
||||
from os import remove
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
|
||||
from PIL.Image import Image
|
||||
|
||||
from huepaper import generate
|
||||
from huepaper.utils import save_image
|
||||
|
||||
|
||||
def test_generation():
|
||||
image = generate()
|
||||
assert isinstance(image, Image)
|
||||
|
||||
|
||||
def test_saving():
|
||||
image = generate(
|
||||
500,
|
||||
500,
|
||||
hue_max=1.0,
|
||||
lum_min=0.3,
|
||||
lum_max=0.6,
|
||||
sat_min=0.8,
|
||||
sat_max=1.0,
|
||||
lines=0.0,
|
||||
)
|
||||
save_image(image, Path("tests/image.jpg"))
|
||||
assert Path("tests/image.jpg").exists()
|
||||
remove(Path("tests/image.jpg"))
|
||||
|
||||
|
||||
def test_shell():
|
||||
assert (
|
||||
run(
|
||||
[
|
||||
"huepaper",
|
||||
"-hue",
|
||||
"0.3",
|
||||
"-lmin",
|
||||
"0.5",
|
||||
"-lmax",
|
||||
"0.3",
|
||||
"-l",
|
||||
"0.5",
|
||||
"-p",
|
||||
"64x36",
|
||||
"-o",
|
||||
"tests/image.jpg",
|
||||
],
|
||||
check=False,
|
||||
).returncode
|
||||
== 0
|
||||
)
|
||||
remove(Path("tests/image.jpg"))
|
||||
|
||||
|
||||
def test_generation_example_1():
|
||||
image = generate(color="lightgreen")
|
||||
assert isinstance(image, Image)
|
||||
|
||||
|
||||
def test_generation_example_2():
|
||||
image = generate(color="#ff7f50", lines_bright=0.05)
|
||||
assert isinstance(image, Image)
|
||||
|
||||
|
||||
def test_generation_example_3():
|
||||
image = generate(hue_max=1.0, lum_min=0.3, lum_max=0.6, sat_min=0.8, sat_max=1.0)
|
||||
assert isinstance(image, Image)
|
||||
|
||||
|
||||
def test_generation_example_4():
|
||||
image = generate(hue_max=0.3, lum_min=0.5, lum_max=0.5, lines=0.5, pixelate="64x36")
|
||||
assert isinstance(image, Image)
|
||||
|
||||
|
||||
def test_generation_example_5():
|
||||
image = generate(
|
||||
lines=0.3,
|
||||
lines_bright=0.1,
|
||||
lines_dark=0.1,
|
||||
emblem=Path("tests/assets/emblem.png"),
|
||||
)
|
||||
assert isinstance(image, Image)
|
Reference in New Issue
Block a user