1
0
Fork
You've already forked squarifier
0
Square Images as a Service
  • Rust 64.5%
  • Nix 22%
  • HTML 9.6%
  • Jinja 3.9%
2025年10月19日 13:51:17 +03:00
ansible Update deps 2025年10月19日 13:51:17 +03:00
src Add request logging 2025年10月19日 13:51:17 +03:00
.gitignore Add flake 2025年10月19日 13:51:17 +03:00
.gitlab-ci.yml Update image to buster 2025年10月19日 13:51:15 +03:00
Cargo.lock Add SQUARIFIER_PORT env var 2025年10月19日 13:51:17 +03:00
Cargo.toml Add SQUARIFIER_PORT env var 2025年10月19日 13:51:17 +03:00
flake.lock Add flake 2025年10月19日 13:51:17 +03:00
flake.nix Add flake 2025年10月19日 13:51:17 +03:00
LICENSE Update deps and license 2025年10月19日 13:51:16 +03:00
README.md Rewrite to axum, change encoding from base64 to % 2025年10月19日 13:51:17 +03:00
rust-toolchain.toml Add flake 2025年10月19日 13:51:17 +03:00

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:

Qurashith

into this:

Squarified Qurashith

The image got cropped and made into a square.

Why?

There are few problems with Roll20 that I was constantly facing:

  1. Too small storage (100 Mb for images)
  2. 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:

  1. Get the request
  2. Download requested image, while the incoming request is waiting
  3. Process it
  4. 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.