# Image upload issue

**URL:** https://meta.discourse.org/t/image-upload-issue/186575
**Category:** Bug
**Created:** [April 12, 2021, 8:01pm UTC](https://meta.discourse.org/t/image-upload-issue/186575 "2021-04-12T20:01:39Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [April 12, 2021, 8:01pm UTC](https://meta.discourse.org/t/image-upload-issue/186575/1 "2021-04-12T20:01:40Z")

</div>

Hello,

I think this fix [FIX: automatically timeout long running image magick commands (#12670) · discourse/discourse@5deda5e · GitHub](https://github.com/discourse/discourse/commit/5deda5ef3ef8763dfe936a313e0dddaa279a1b04) is broke the multiple image upload. If i try to upload **3** , _ **~5-6mb** _ image it will not work, every time it shows this error. I think because of the 20sec timeout.

`lib/discourse.rb:93:in 'exec': An error happened when converting from PNG to JPG.`

Thank you 🙂

---

<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: [April 12, 2021, 9:25pm UTC](https://meta.discourse.org/t/image-upload-issue/186575/2 "2021-04-12T21:25:52Z")

</div>

Does this fail on this site? Can you try uploading the image (provided it is kids appropriate)

We need a limit here, we can not push it much beyond 20 seconds

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [April 12, 2021, 9:52pm UTC](https://meta.discourse.org/t/image-upload-issue/186575/3 "2021-04-12T21:52:10Z")

</div>

Hi Sam,  
Last time I tried it faild here too that is why I categorized it as bug but now it uploaded. On my site it every time fail. Size ~6mb / photo

 ![IMG_20210412_233324](https://global.discourse-cdn.com/meta/original/3X/1/b/1b5be7071fcebf4d2769564944dcf862ec69fbb4.jpeg) ![IMG_20210412_233313](https://global.discourse-cdn.com/meta/original/3X/3/5/35107812a4657a7969af02e4e4ad690932e65394.jpeg) ![IMG_20210412_233253](https://global.discourse-cdn.com/meta/original/3X/1/e/1e9bc0ab94103ed8a191b2ed0d036725b06363b2.jpeg)

---

<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: [April 13, 2021, 1:43am UTC](https://meta.discourse.org/t/image-upload-issue/186575/4 "2021-04-13T01:43:20Z")

</div>

Oh this is tricky, I want to debug locally. Can you upload one of the original images somewhere for me to download so I can test how long the various image magick commands take.

I can consider adding a “longer timeout” site setting, but I am somewhat concerned converting this simple image from png → jpg is taking upwards of 10 seconds.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [April 13, 2021, 8:13am UTC](https://meta.discourse.org/t/image-upload-issue/186575/5 "2021-04-13T08:13:07Z")

</div>

Thank you! I uploaded some images to Mega [File folder on MEGA](https://mega.nz/folder/pVkQjZjA#Ccz1bOQ8sndTHvefQWERjw)

---

<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: [April 14, 2021, 5:34am UTC](https://meta.discourse.org/t/image-upload-issue/186575/6 "2021-04-14T05:34:40Z")

</div>

Can you confirm you are on a standard docker install.

I just tested one of your images above, we run 2 commands in the container.

`timeout -k 10.0 5 identify -format %Q image.jpg`

and

` timeout -k 40.0 20 convert jpeg:original.jpg -auto-orient -background white -interlace none -flatten -quality 90 jpg:/tmp/target.jpg`

The first command takes `0.27` of the allotted 5 seconds on my local system.

The second command takes `1.3` seconds of the allotted 20 seconds.

Can you tell me a bit more about your install, and the particular performance of the server it is running on?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [April 14, 2021, 5:55am UTC](https://meta.discourse.org/t/image-upload-issue/186575/7 "2021-04-14T05:55:10Z")

</div>

Thank you Sam, to checked this. Yes standard docker install. Yesterday I upgraded the server because so much slow down the whole website also… And did a rebuild. With the server upgrade it works fine. Just tested now. Digital Ocean has a new plan about 2 month with Premium Intel CPU and the other which we had the Regular getting much weaker.

The old server 🔽  
Basic - Shared CPU 2 vCPUs 4 GB 60 GB

The new server 🔽  
Basic - Premium Intel Shared CPU 2 vCPUs 4 GB 60 GB

Sorry for this topic. 20 seconds is enough. And thank you again! 🙂

---

<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: [April 14, 2021, 6:07am UTC](https://meta.discourse.org/t/image-upload-issue/186575/8 "2021-04-14T06:07:56Z")

</div>

Yeah I think we are behaving correctly here.

If we do not timeout there is high risk that these under powered instances could get dominated by users uploading images. 20 seconds is a huge amount of CPU to give people for resizing images.

---

<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: [April 14, 2021, 10:00pm UTC](https://meta.discourse.org/t/image-upload-issue/186575/9 "2021-04-14T22:00:39Z")

</div>

This topic was automatically closed after 15 hours. New replies are no longer allowed.
