Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build
run: make clean buiild test
run: make clean build test
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ init:
build: docker.build
clean: docker.clean py-clean

docs:
docs: docs.vhs docs.jinja #docs.rotations
docs.jinja:
${pynchon.run} jinja render README.md.j2
PS1="$$ " sh -c "${pynchon.run} vhs apply"

python demo.py img/icon.png --stream > img/demo.gif
docs.vhs:; PS1="$$ " sh -c "${pynchon.run} vhs apply"
docs.rotations:
python demo.py img/graph.png --bg lightblue --rotation x --stream > img/rx.gif
python demo.py img/graph.png --bg lightblue --rotation y --stream > img/ry.gif
python demo.py img/graph.png --bg lightblue --rotation s --stream > img/rs.gif
python demo.py img/graph.png --bg lightblue --rotation j --stream > img/rj.gif
python demo.py img/graph.png --bg lightblue --rotation w --stream > img/rw.gif
python demo.py img/graph.png --bg lightblue --rotation f --stream > img/rf.gif
python demo.py img/graph.png --bg lightblue --rotation exit-ul --stream > img/rul.gif
python demo.py img/graph.png --bg lightblue --rotation exit-ur --stream > img/rur.gif
python demo.py img/graph.png --bg lightblue --rotation exit-lr --stream > img/rlr.gif
python demo.py img/graph.png --bg lightblue --rotation exit-ll --stream > img/rll.gif


docker.clean:
docker rmi $(DOCKER_IMAGE_NAME) >/dev/null || true
Expand Down
97 changes: 84 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,110 @@ pip install -r requirements.txt
Usage: demo.py [OPTIONS] IMG_PATH

Options:
--range TEXT Range to rotate through
--stream / --no-stream Stream output in raw format (for use with pipes).
Implies --animate
--display / --no-display Display output with chafa
--view / --no-view View a file with chafa (don't generate anything)
--output-dir TEXT Output directory for frames
--output-file TEXT Output file for animated gif
--img-shape TEXT Ideal image shape in WxH format (optional)
--help Show this message and exit.
--bg TEXT Background color to pass to chafa
--display Display output with chafa
--invert Pass --invert to chafa
--img-shape TEXT Ideal image shape in WxH format (optional)
--duration TEXT Duration argument to pass to chafa
--output-dir TEXT Output directory for frames
--output-file TEXT Output file for animated gif
--range TEXT Range to rotate through
--stream / --no-stream Stream output in raw format (for use with pipes).
Implies --animate
--verbose Whether or not ffmpeg-stderr is displayed
--view View a file with chafa (generates nothing)
--rotation TEXT One of { x | y | yz }
--speed TEXT Speed factor to pass to ffmpeg (default=.08)
--stretch Whether to pass --stretch to chafa
--help Show this message and exit.

```

You can also set `LOGLEVEL=debug` for more info.

-------------------------------------

## Usage from Docker

**A few examples of usage from docker:**
A few examples of usage from docker:

**Saving an animated gif to a file:**

```bash
# Saves the animated gif to a file.
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --stream > demo.gif
```

<p align=center>
<img width=25% align=center src=img/demo.gif>
</p>

**Rendering a gif, then displaying it in a terminal-friendly way with chafa:**

```bash
# Renders a gif from a static image, then displays it in a terminal-friendly way with chafa
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --display
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --display --stretch --bg lightblue
```

<p align=center>
<img width=50% align=center src=img/demo.chafa.gif>
</p>

Note that this tries to respect transparency in the original image, but for more contrast you can effectively add highlights by passing '--bg' arguments that go through to chafa.

------------------------------

**Changing axis of rotation**

The rotation can be controlled to create a bunch of different effects:

```bash
$ docker run -it --rm -v `pwd`:/workspace \
-w /workspace robotwranglers/imgrot \
img/icon.png \
--display --stretch \
--bg darkgreen \
--rotation <some-rotation here>
```

<p align=center>
<table>
<tr>
<th>x</th>
<th>y</th>
<th>s,swivel</th>
</tr>
<tr>
<td>
<img src=img/rx.gif></td>
<td>
<img src=img/ry.gif>
</td>
<td><img src=img/rs.gif></td>
</tr>
<tr>
<th>j,jitter</th>
<th>w,wobble</th>
<th>f,flip</th>
</tr>
<tr>
<td>
<img src=img/rj.gif></td>
<td>
<img src=img/rw.gif>
</td>
<td><img src=img/rf.gif></td>
</tr>
<tr>
<th>exit-ul</th>
<th>exit-ur</th>
<th>exit-lr</th>
</tr>
<tr>
<td>
<img src=img/rul.gif></td>
<td>
<img src=img/rur.gif>
</td>
<td><img src=img/rlr.gif></td>
</tr>
</table>
</p>
72 changes: 68 additions & 4 deletions README.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,91 @@ pip install -r requirements.txt
{{bash('python demo.py --help')}}
```

You can also set `LOGLEVEL=debug` for more info.

-------------------------------------

## Usage from Docker

**A few examples of usage from docker:**
A few examples of usage from docker:

**Saving an animated gif to a file:**

```bash
# Saves the animated gif to a file.
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --stream > demo.gif
```

<p align=center>
<img width=25% align=center src=img/demo.gif>
</p>

**Rendering a gif, then displaying it in a terminal-friendly way with chafa:**

```bash
# Renders a gif from a static image, then displays it in a terminal-friendly way with chafa
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --range 360 --img-shape 200x200 --display
$ docker run -it --rm -v `pwd`:/workspace -w /workspace robotwranglers/imgrot img/icon.png --display --stretch --bg lightblue
```

<p align=center>
<img width=50% align=center src=img/demo.chafa.gif>
</p>

Note that this tries to respect transparency in the original image, but for more contrast you can effectively add highlights by passing '--bg' arguments that go through to chafa.

------------------------------

**Changing axis of rotation**

The rotation can be controlled to create a bunch of different effects:

```bash
$ docker run -it --rm -v `pwd`:/workspace \
-w /workspace robotwranglers/imgrot \
img/icon.png \
--display --stretch \
--bg darkgreen \
--rotation <some-rotation here>
```

<p align=center>
<table>
<tr>
<th>x</th>
<th>y</th>
<th>s,swivel</th>
</tr>
<tr>
<td>
<img src=img/rx.gif></td>
<td>
<img src=img/ry.gif>
</td>
<td><img src=img/rs.gif></td>
</tr>
<tr>
<th>j,jitter</th>
<th>w,wobble</th>
<th>f,flip</th>
</tr>
<tr>
<td>
<img src=img/rj.gif></td>
<td>
<img src=img/rw.gif>
</td>
<td><img src=img/rf.gif></td>
</tr>
<tr>
<th>exit-ul</th>
<th>exit-ur</th>
<th>exit-lr</th>
</tr>
<tr>
<td>
<img src=img/rul.gif></td>
<td>
<img src=img/rur.gif>
</td>
<td><img src=img/rlr.gif></td>
</tr>
</table>
</p>
Loading