# Unable to resize images after uploading

**URL:** https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183
**Category:** Bug
**Created:** [2015年八月16日 18:24 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183 "2015-08-16T18:24:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ky\_metro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ky_metro/32/42807_2.png) [@ky\_metro](https://meta.discourse.org/u/ky_metro)
#### Post date: [2015年八月16日 18:24 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183/1 "2015-08-16T18:24:05Z")

</div>

Continuing the discussion from [Resize images after uploading](https://meta.discourse.org/t/resize-images-after-uploading/30575/7):

> [@Resize images after uploading](https://meta.discourse.org/t/resize-images-after-uploading/30575/7):
>
> This is now done. We’ll accept images of up to 10MB and then downsize them to the maximum allowed image size 🐆
> 
> [FEATURE: automatically downsize large images · discourse/discourse@ffbaf8c · GitHub](https://github.com/discourse/discourse/commit/ffbaf8c54269df2ce510de91245760fddce09896)

* * *

I’ve been looking forward to this feature for a long time. I just upgraded to the current version of Discourse, and it’s not working. I’ve tried to reproduce this in various places with varying results.

- This is the test image, 5.48 mb: [https://www.ushpa.aero/media/photos/pg\_2008\_00\_hires.jpg](https://www.ushpa.aero/media/photos/pg_2008_00_hires.jpg)

- At my [main website](http://forum.driveonwood.com), uploading this image goes fine until it reaches 100%, then it stays at “Uploading 100%” forever.

- On a small dev install (also on current version) it gets to 100% then starts over from 0%. Repeats this indefinitely.

- On [http://try.discourse.org](http://try.discourse.org) (and here on meta) it uploads to 100% then says “Sorry, the image you are trying to upload is too big (maximum size is 3072KB), please resize it and try again.” Possibly these are not on the latest version?

Steps to repro:

1. Find an image larger than the image size limit but less than 10MB.
2. Try to upload it.

---

<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: [2015年八月16日 20:26 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183/2 "2015-08-16T20:26:37Z")

</div>

Can you clarify @zogstrip?

This image storage size limit is not enabled on try or meta at the moment, so you would have to enable the limit and then test on your site.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2015年八月17日 16:59 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183/3 "2015-08-17T16:59:22Z")

</div>

Ok, I’ve found the 🐛 . It happens that `IO.size` is cached and while we were actually downsizing the image, the algorithm was always checking the same file size… Thus resulting in an error when uploading a file larger than the image size limit…

[https://github.com/discourse/discourse/commit/827ea641b04396e2cc3f5c8298c3ad475b1a4eff](https://github.com/discourse/discourse/commit/827ea641b04396e2cc3f5c8298c3ad475b1a4eff)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2015年八月17日 16:59 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183/4 "2015-08-17T16:59:24Z")

</div>



---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2015年八月17日 20:43 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183/5 "2015-08-17T20:43:41Z")

</div>

This is most likely the source of the other bug I reported with uploads taking so long I gave up - they were going to take forever!

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2015年八月17日 20:44 UTC](https://meta.discourse.org/t/unable-to-resize-images-after-uploading/32183/6 "2015-08-17T20:44:16Z")

</div>

Yup, especially for large PNGs…
