# Optimize images before uploading?

**URL:** https://meta.discourse.org/t/optimize-images-before-uploading/17150
**Category:** Feature
**Created:** [July 3, 2014, 6:33am UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150 "2014-07-03T06:33:47Z")
**Posts on this page:** 18
**Page:** 3

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [November 6, 2018, 3:20am UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/44 "2018-11-06T03:20:16Z")

</div>

> [@Falco](#):
>
> I think we could sponsor a plugin that experiments with [GitHub - nodeca/pica: Resize image in browser with high quality and high speed](https://github.com/nodeca/pica).

Was that given a go?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 12, 2018, 8:04pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/45 "2018-11-12T20:04:38Z")

</div>

Another example of what is possible on ImageOptimization in browser:

> **[Squoosh](https://squoosh.app/)**
>
> Squoosh is the ultimate image optimizer that allows you to compress and compare images with different codecs in your 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.

![](https://global.discourse-cdn.com/meta/optimized/4X/0/c/8/0c84da006d5546f27821ee7452b19d0d47cd98f6_2_690x388.jpeg)https://www.youtube.com/embed/ipNW6lJHVEs?feature=oembed&wmode=opaque&list=PLNYkxOF6rcIDjlCx1PcphPpmf43aKOAdF&start=0

---

<div class="post-metadata">

### Author: ![Dmitry\_Krasnoperov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_krasnoperov/32/65079_2.png) [@Dmitry\_Krasnoperov](https://meta.discourse.org/u/Dmitry_Krasnoperov)
#### Post date: [December 2, 2018, 10:58pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/46 "2018-12-02T22:58:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![John\_Lehmann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/john_lehmann/32/140084_2.png) [@John\_Lehmann](https://meta.discourse.org/u/John_Lehmann)
#### Post date: [May 13, 2019, 10:56pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/47 "2019-05-13T22:56:25Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 13, 2019, 11:03pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/48 "2019-05-13T23:03:21Z")

</div>

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. 🙂

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 13, 2019, 11:05pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/49 "2019-05-13T23:05:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![John\_Lehmann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/john_lehmann/32/140084_2.png) [@John\_Lehmann](https://meta.discourse.org/u/John_Lehmann)
#### Post date: [May 13, 2019, 11:51pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/50 "2019-05-13T23:51:11Z")

</div>

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

> [@Set up file and image uploads to S3](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229):
>
> So, you want to use S3 to handle image uploads? Here’s the definitive guide, but also see [Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916) to see how to configure your app.yml. S3 registration Head over to [https://aws.amazon.com/free/](https://aws.amazon.com/free/) and click on [Create a Free Account] During the create account process, make sure you provide payment information, otherwise you won’t be able to use S3. There’s no registration fee, you will only be charged for [what you use](https://aws.amazon.com/s3/pricing/), if you exceed the [AWS …](https://aws.amazon.com/free/)

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?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 13, 2019, 11:55pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/51 "2019-05-13T23:55:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 14, 2019, 12:03am UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/52 "2019-05-14T00:03:20Z")

</div>

> [@John\_Lehmann](#):
>
> 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?

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

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [November 1, 2020, 2:46pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/53 "2020-11-01T14:46:10Z")

</div>

Most of our users use mobile data and sometimes their internet speed may be 3G or less. Many times, the quality of the images they send is not important and speed is more important to them.

In 3G upload (about 2Mbps), sending a 5MB image takes about 20 seconds, and this time may be much longer as the speed decreases.

> [@Falco](#):
>
> Looks like a cool, optional thing for Discourse.

As @Falco points out, with similar algorithms, the size of a 5 MB image can be reduced to 190 KB by compressing at the client-side and reducing the dimensions. This way both sending faster (in 3G, about 1 second) and fewer resources are needed.

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/5/75f6a0eed88c2278b08f846459a677809cca7e83.jpeg)

_The screenshot above shows the sending of  
the image in the Telegram Messenger_

Is there such a feature in the Roadmap? If the answer is yes, is it far or near?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [November 1, 2020, 4:14pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/54 "2020-11-01T16:14:22Z")

</div>

> [@nildarar](#):
>
> Is there such a feature in the Roadmap? If the answer is yes, is it far or near?

It’s something we want to eventually do, but it’s not in our public roadmap at #releases.

I will write a RFC on this feature this week so we can move forward with it, at least specification wise.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 1, 2020, 6:03pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/56 "2020-11-01T18:03:54Z")

</div>

This is already possible in iOS. Like so (will post screenshot stand by)

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/2/c2ebb11b7da69c73f80e865200ae04f0b9953888.jpeg)

Via

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/f/7f4784f6fc7c3e666c50dec4163f613282fd7286.jpeg)

I selected “large”. It still screws up the orientation though!

---

<div class="post-metadata">

### Author: ![nildarar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nildarar/32/331927_2.png) [@nildarar](https://meta.discourse.org/u/nildarar)
#### Post date: [November 2, 2020, 6:26am UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/57 "2020-11-02T06:26:30Z")

</div>

> [@Falco](#):
>
> I will write a RFC on this feature this week so we can move forward with it, at least specification wise.

Thanks, that’s great 🙏 👍

> [@codinghorror](#):
>
> This is already possible in iOS

I wish Android learns too 😅

---

<div class="post-metadata">

### Author: ![ozkn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ozkn/32/196013_2.png) [@ozkn](https://meta.discourse.org/u/ozkn)
#### Post date: [November 2, 2020, 8:13am UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/58 "2020-11-02T08:13:05Z")

</div>

In addition to this feature, lightbox can be an image rotation button

---

<div class="post-metadata">

### Author: ![aaii](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@aaii](https://meta.discourse.org/u/aaii)
#### Post date: [December 4, 2020, 5:11pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/59 "2020-12-04T17:11:56Z")

</div>

This library looks interesting: [GitHub - silvia-odwyer/photon: ⚡ Rust/WebAssembly image processing library · GitHub](https://github.com/silvia-odwyer/photon)

A wasm binary seems like the ideal choice because it’ll be fast and memory efficient.

---

<div class="post-metadata">

### Author: ![mike1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mike1/32/202318_2.png) [@mike1](https://meta.discourse.org/u/mike1)
#### Post date: [December 7, 2020, 9:07pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/60 "2020-12-07T21:07:26Z")

</div>

I’m curious if client side image compression, when possible, would have a notable impact on web server performance with low spec hosting (eg shared cpu digital ocean instance).

I see a spike in CPU utilization occasionally that I believe correlates with users uploading images that need to be compressed. Has anyone seen similar impact?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [April 22, 2021, 9:37pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/61 "2021-04-22T21:37:53Z")

</div>

Discussing the implementation at [Optional image optimization before upload](https://meta.discourse.org/t/optional-image-optimization-before-upload/187656)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [April 22, 2021, 9:37pm UTC](https://meta.discourse.org/t/optimize-images-before-uploading/17150/62 "2021-04-22T21:37:57Z")

</div>



[Previous page](https://meta.discourse.org/t/optimize-images-before-uploading/17150.md?page=2)
