spacebarchat / server

Spacebar server - A reimplementation of the Discord.com backend, built with Typescript and love
https://spacebar.chat
GNU Affero General Public License v3.0
1.49k stars 250 forks source link

Local/Built-in image proxy #1126

Closed DEVTomatoCake closed 3 months ago

DEVTomatoCake commented 5 months ago

Currently, there's support for the Imagor image proxy. However, not everyone might be able to run or install it everywhere.

This PR adds a local image proxy which can be configured using the cdn_imagorServerUrl config. Currently, it has to be configured as <Base instance URL>/imageproxy.

  1. Hash is supported so external users cannot use the proxy with different URLs
  2. URL format is compatible with Imagor/Thumbor
  3. Resizing is supported using the following fallbacks:
    1. Try sharp (requires C binaries for build)
    2. Try jimp (pure JS, added as optional dependency)
    3. Nothing, image is returned as-is

Discussion

(Doesn't have to be on GitHub, Spacebar/Discord is also possible.)

Code

Concept

Config

MaddyUnderStars commented 4 months ago

I don't believe that this is in scope for spacebar, and it has additional performance considerations. Using Imagor makes more sense to me, as it's a dedicated tool written in a more performant language.

MaddyUnderStars commented 4 months ago

You don't need to close it if you want to wait for what the others have to say. @Puyodead1 @TheArcaneBrony

TheArcaneBrony commented 4 months ago

I don't believe this is out of scope for Spacebar? Besides, I don't think performance considerations are that important. For those looking for better performance, Imagor seems to remain available as an option?

DEVTomatoCake commented 4 months ago

Imagor seems to remain available as an option?

Yes, it should still be possible to use Imagor and that should be preferred too, but this PR helps if you cannot use Imagor yet.

Puyodead1 commented 3 months ago

honestly idfk, it seems like it could be useful

MaddyUnderStars commented 3 months ago

And I've been outvoted! @DEVTomatoCake If you can fix the conflicts, I'll merge it