Optimize images before uploading?

Was that given a go?

Another example of what is possible on ImageOptimization in browser:

https://squoosh.app/

This video goes over the tech. They compiled the state of art codecs (the same we use on the server for Discourse) to WASM :exploding_head:

Looks like a cool, optional thing for Discourse.

The WASM for mozjpeg can be compressed to 48k and the WASM for OptiPNG is 93k.

9 curtidas

My image folder grows to 42.3 GB.
So I think I need to figure out image processing and storing in Discourse :slight_smile:

1 curtida

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. :slight_smile:

We already have max_image_megapixels site setting, can you try toning that down?

2 curtidas

@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?

1 curtida

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.

2 curtidas

There is a rake task that will do it, but I’d say that sooner is better than later. :slight_smile:

1 curtida

A maioria dos nossos usuários usa dados móveis e, às vezes, a velocidade da internet deles pode ser 3G ou inferior. Muitas vezes, a qualidade das imagens que enviam não é importante e a velocidade é mais importante para eles.

Em um upload 3G (cerca de 2 Mbps), enviar uma imagem de 5 MB leva cerca de 20 segundos, e esse tempo pode ser muito maior à medida que a velocidade diminui.

Como @Falco aponta, com algoritmos semelhantes, o tamanho de uma imagem de 5 MB pode ser reduzido para 190 KB ao comprimir no lado do cliente e reduzir as dimensões. Dessa forma, tanto o envio é mais rápido (em 3G, cerca de 1 segundo) quanto são necessários menos recursos.

A captura de tela acima mostra o envio da imagem no Telegram Messenger

Existe tal recurso no Roadmap? Se a resposta for sim, está próximo ou distante?

É algo que queremos fazer eventualmente, mas não está em nosso roadmap público em #releases.

Vou escrever um RFC sobre esse recurso esta semana para que possamos avançar com ele, pelo menos em termos de especificação.

7 curtidas

Isso já é possível no iOS. Assim (vou postar a captura de tela, aguarde)

Através de

Selecionei “grande”. Ainda assim, a orientação fica errada!

7 curtidas

Obrigado, isso é ótimo :pray: :+1:

Desejo que o Android aprenda também :sweat_smile:

Além dessa funcionalidade, o lightbox pode ser um botão de rotação de imagens

Essa biblioteca parece interessante: GitHub - silvia-odwyer/photon: ⚡ Rust/WebAssembly image processing library · GitHub

Um binário wasm parece ser a escolha ideal, pois será rápido e eficiente em termos de memória.

3 curtidas

Tenho curiosidade sobre se a compressão de imagens no lado do cliente, quando possível, teria um impacto notável no desempenho do servidor web em hospedagem de baixa especificação (por exemplo, instância Digital Ocean com CPU compartilhada).

Observo picos ocasionais na utilização da CPU que acredito estarem relacionados ao upload de imagens pelos usuários que precisam ser comprimidas. Alguém já viu um impacto semelhante?

2 curtidas

Discussando a implementação em Optional image optimization before upload

1 curtida