<p>Craft release 2.6.2911 has made a significant improvement, and with it, our troublesome animated GIFs are transforming correctly.</p>

CC BY-SA 3.0
2016-08-17T03:44:12.463Z
2016-08-17T03:44:12.463Z
Jay Haase
<p>We are seeing the following symptoms:</p>

<ol>
<li>We routinely encounter stuck <code>Generating pending image transforms</code> tasks and have to manually mark the tasks as failed using SQL in the table <code>craft_tasks</code>.</li>
<li>Broken image links on pages that use image transforms. This can sometimes be fixed with multiple page refreshes.</li>
<li>The <code>phperrors.log</code> message <code>PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /.../craft/app/vendor/imagine/imagine/lib/Imagine/Imagick/Image.php on line 228</code>, even though are php.ini sets the max execution time to 300. I am pretty sure this is from the hard-coded limit set in <code>AssetTransformsService.php</code></li>
</ol>

<p>Our site has a large variety of images; the site is for a advertising agency. We can reproduce the problem pretty easily with animated GIFs, although size of the GIF does not alone seem to be the factor, because some 2mb GIFs never transform, while some 4mb GIFs transform very quickly.</p>

<p>I think there are a few issues going on:</p>

<ul>
<li>The 120 second limit is affecting some images that take a long time to transform, resulting in a exceeded exec time log message.</li>
<li>Some images are never completing the transform process, seemingly regardless of the transform time, resulting in an exceeded exec time log message.</li>
<li>Some images mysteriously get stuck in the image transform process, resulting in no log messages.</li>
</ul>

<p><strong>Questions</strong></p>

<ol>
<li>What is the recommended way for increasing the hard-coded 120 second limit?</li>
<li>How can we track down the cause(s) of the stuck transforms?</li>
</ol>

<p><strong>AssetTransformsService.php Background</strong></p>

<p>The Craft core file <code>craft/app/services/AssetTransformsService.php</code> has a hard-coded PHP <code>max_execution_time</code> of 120 seconds.</p>

<pre><code>line 421: ini_set('max_execution_time', 120);
</code></pre>

<p><strong>Some Craft Info</strong></p>

<p>We are using Craft CMS version 2.6</p>

<p><strong>Some Sever Info</strong></p>

<p>We have <code>imagick</code> enabled as our image driver.</p>

<pre><code>imagick module version  3.4.1
Imagick compiled with ImageMagick version   ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org
Imagick using ImageMagick library version   ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org
ImageMagick release date    2016-06-16
</code></pre>

CC BY-SA 3.0
2016-08-11T17:08:18.200Z
That probably a bug on our end, but are you sure the transforms are actually taking that long and not just hanging?  Do they eventually complete if you up that value to 1000 or something?
Brad Bell
CC BY-SA 3.0
2016-08-11T18:22:09.200Z
@BradBell: Increasing the time helped some images and had no affect on others.
Jay Haase
CC BY-SA 3.0
2016-08-11T23:58:37.737Z
Are you sure the 120 second limit is the issue here, then?  How big and what types of images are taking longer than your increased amount?
Brad Bell
CC BY-SA 3.0
2016-08-12T15:03:53.437Z
@BradBell: I have added more info to the question.
Jay Haase
CC BY-SA 3.0
2016-08-15T22:48:04.063Z
Can you email support@craftcms.com so we can send you a few patched files to test some animated GIF optimizations?
Brad Bell
CC BY-SA 3.0
2016-08-17T03:41:58.107Z
@BradBell: the latest release (2.6.2911) with your patches seems to have helped a bunch. The animated GIFs we were having problems are now transforming. Thank you for your world class support!
Jay Haase
<image-transforms>
Image Transform Problems, Timeouts, Stuck Transforms
# Image Transform Problems, Timeouts, Stuck Transforms

(Asked by: username_0 on 2016-08-11)

We are seeing the following symptoms:

We routinely encounter stuck Generating pending image transforms tasks and have to manually mark the tasks as failed using SQL in the table craft_tasks.
Broken image links on pages that use image transforms. This can sometimes be fixed with multiple page refreshes.
The phperrors.log message PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /.../craft/app/vendor/imagine/imagine/lib/Imagine/Imagick/Image.php on line 228, even though are php.ini sets the max execution time to 300. I am pretty sure this is from the hard-coded limit set in AssetTransformsService.php

Our site has a large variety of images; the site is for a advertising agency. We can reproduce the problem pretty easily with animated GIFs, although size of the GIF does not alone seem to be the factor, because some 2mb GIFs never transform, while some 4mb GIFs transform very quickly.
I think there are a few issues going on:

The 120 second limit is affecting some images that take a long time to transform, resulting in a exceeded exec time log message.
Some images are never completing the transform process, seemingly regardless of the transform time, resulting in an exceeded exec time log message.
Some images mysteriously get stuck in the image transform process, resulting in no log messages.

Questions

What is the recommended way for increasing the hard-coded 120 second limit?
How can we track down the cause(s) of the stuck transforms?

AssetTransformsService.php Background
The Craft core file craft/app/services/AssetTransformsService.php has a hard-coded PHP max_execution_time of 120 seconds.
line 421: ini_set('max_execution_time', 120);

Some Craft Info
We are using Craft CMS version 2.6
Some Sever Info
We have imagick enabled as our image driver.
imagick module version  3.4.1
Imagick compiled with ImageMagick version   ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org
Imagick using ImageMagick library version   ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org
ImageMagick release date    2016-06-16

**Tags:** image-transforms
> **Comments:**
> **username_1**: That probably a bug on our end, but are you sure the transforms are actually taking that long and not just hanging?  Do they eventually complete if you up that value to 1000 or something?  
> **username_0**: @BradBell: Increasing the time helped some images and had no affect on others.  
> **username_1**: Are you sure the 120 second limit is the issue here, then?  How big and what types of images are taking longer than your increased amount?  
> **username_0**: @BradBell: I have added more info to the question.  
> **username_1**: Can you email support@craftcms.com so we can send you a few patched files to test some animated GIF optimizations?  
> **username_0**: @BradBell: the latest release (2.6.2911) with your patches seems to have helped a bunch. The animated GIFs we were having problems are now transforming. Thank you for your world class support!  

---

## 1 answers

### Answer by username_0 on 2016-08-17. Score: 3 | Accepted answer

Craft release 2.6.2911 has made a significant improvement, and with it, our troublesome animated GIFs are transforming correctly.


---

