- Rust 64.5%
- Nix 22%
- HTML 9.6%
- Jinja 3.9%
| ansible | Update deps | |
| src | Add request logging | |
| .gitignore | Add flake | |
| .gitlab-ci.yml | Update image to buster | |
| Cargo.lock | Add SQUARIFIER_PORT env var | |
| Cargo.toml | Add SQUARIFIER_PORT env var | |
| flake.lock | Add flake | |
| flake.nix | Add flake | |
| LICENSE | Update deps and license | |
| README.md | Rewrite to axum, change encoding from base64 to % | |
| rust-toolchain.toml | Add flake | |
Token Squarifier
This is a tiny project that help me run my D&D and Pathfinder games at Roll20.
Where?
You can try it at https://squarifier.bemyak.net
What?
In short, it dynamically turns this:
into this:
The image got cropped and made into a square.
Why?
There are few problems with Roll20 that I was constantly facing:
- Too small storage (100 Mb for images)
- When you insert non-rectangular token, it gets stretched in order to fill the square
I found the solution for the first problem, which is described at the end of my blog post Rolling like a Pro. In short, I'm now able to insert images as links, which doesn't eat any space at all.
But now the second problem got much worse: you rarely can find a square image on the internet, so you need to download it, crop, make square and this nullifies any win from the #1, because you don't have an image URL now, and you need to upload it again.
To solve this, this project was created. It acts like a proxy that changes your images in the way you'd probably want it: cropped and square. 🎉
How?
We need to process images really quickly in order to be able to respond as fast as possible. We still need to:
- Get the request
- Download requested image, while the incoming request is waiting
- Process it
- Answer the request with a processed image
So, the overall latency is around 2 * original_request_latency
To minimize it further you can run Squarifier locally or on some server nearby that has public IP and/or DNS name.