Was that given a go?
Another example of what is possible on ImageOptimization in browser:
This video goes over the tech. They compiled the state of art codecs (the same we use on the server for Discourse) to WASM 
Looks like a cool, optional thing for Discourse.
The WASM for mozjpeg can be compressed to 48k and the WASM for OptiPNG is 93k.
My image folder grows to 42.3 GB.
So I think I need to figure out image processing and storing in Discourse ![]()
I’m not sure if this is the right topic to post on, but I am very interested in knowing if there’s a way to automatically downsize images before they get stored in my discourse. My community is going to be very image heavy.
I’m less than a week in and already 350 MB used and not even open to general public yet. Would like to be able to resize images down to some resolution so that I keep them < 1MB or something like that (based on image resolution though as per norm I think).
I’d recommend using Digital Ocean spaces or S3 for your images so you don’t need to worry about space so much.
It seems unlikely that a community that really likes images is going to want really bad ones. 
We already have max_image_megapixels site setting, can you try toning that down?
@sam Yes, but, the problem is there’s a big difference between reducing some resolution that most people won’t even notice (IMO big diminishing returns), versus blocking them from uploading at all. On my main site, I downsize to 1500x and no one cares. But if they can’t upload it’s a huge hassle.
@pfaffman This sounds perfect, I guess I need to read:
I wonder, this is probably something I need to do sooner than later, because I’m guessing trying to migrate the files from discourse hosting to s3 could be hard?
I do support a simpler mechanism longer term, something like
All images must be smaller than 500k but allow people to upload stuff up to 2000k and fix on server if needed by either downsizing or reducing resolution. Try resizing on client first if possible.
But yeah, getting to this level of fidelity will take quite a while.
There is a rake task that will do it, but I’d say that sooner is better than later. ![]()
La maggior parte dei nostri utenti utilizza i dati mobili e, a volte, la loro velocità di connessione può essere pari o inferiore a 3G. Spesso, la qualità delle immagini che inviano non è prioritaria; per loro è più importante la velocità.
Con un upload in 3G (circa 2 Mbps), l’invio di un’immagine da 5 MB richiede circa 20 secondi, e questo tempo può aumentare notevolmente al diminuire della velocità.
Come ha sottolineato @Falco, con algoritmi simili, è possibile ridurre le dimensioni di un’immagine da 5 MB a 190 KB comprimendola lato client e riducendo le dimensioni. In questo modo, l’invio risulta più veloce (in 3G, circa 1 secondo) e si richiedono meno risorse.
Esiste una funzionalità del genere nella Roadmap? Se sì, è prevista a breve o a lungo termine?
È qualcosa che vorremmo fare alla fine, ma non è nella nostra roadmap pubblica su #releases.
Scriverò una RFC su questa funzionalità questa settimana in modo da poter procedere, almeno a livello di specifica.
Questo è già possibile in iOS. Come si vede (pubblicherò uno screenshot, attendete)
Tramite
Ho selezionato “grande”. Tuttavia, continua a sbagliare l’orientamento!
Grazie, è fantastico
![]()
Spero che anche Android impari ![]()
Oltre a questa funzionalità, il lightbox può essere un pulsante di rotazione delle immagini
Questa libreria sembra interessante: GitHub - silvia-odwyer/photon: ⚡ Rust/WebAssembly image processing library · GitHub
Un file binario wasm sembra la scelta ideale perché sarà veloce ed efficiente in termini di memoria.
Sono curioso di sapere se la compressione delle immagini lato client, quando possibile, abbia un impatto significativo sulle prestazioni del server web su hosting di bassa fascia (ad esempio, un’istanza DigitalOcean con CPU condivisa).
Osservo occasionalmente picchi nell’utilizzo della CPU che ritengo correlati al caricamento di immagini da parte degli utenti che necessitano di compressione. Qualcuno ha riscontrato un impatto simile?
Discussione sull’implementazione su Optional image optimization before upload


