Hypfer / ICantBelieveItsNotValetudo

A Valetudo companion service which renders maps to pngs
Apache License 2.0
129 stars 80 forks source link

Automatically crop whitespace #21

Closed LordMike closed 3 years ago

LordMike commented 4 years ago

As foretold by the docs, I have huge blobs of whitespace on my map. Would it be possible to create a feature that automatically crops this, by removing all-white rows and columns of pixels?

image

LordMike commented 4 years ago

Note, I've found a quick way to do this. Jimp has an autocrop feature.

alceasan commented 4 years ago

Thanks @LordMike, it works like a charm. Manual cropping doesn't work very well, but using autocrop isn't necessary in my opinion.

We could use a new conf variable to set autocrop, and just make the image.autocrop() call in Tools.js depending on its value.