ImageBundle icon indicating copy to clipboard operation
ImageBundle copied to clipboard

cropResize gif time out

Open rolandow opened this issue 11 years ago • 1 comments

I'm trying to cropResize a gif image. It's not an animation. The php script times out. I have no issues with jpg/png.

Image::open($uploadedFile->getRealPath())
    ->cropResize(
        $this->container->getParameter('attachment_max_width'),
        $this->container->getParameter('attachment_max_height')
    )
    ->save($uploadedFile->getRealPath());

Error/stacktrace:

[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /home/roland/projects/MbMbisBundle/Symfony/vendor/gregwar/image/Gregwar/Image/Adapter/GD.php on line 424, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP Stack trace:, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   1. {main}() /home/roland/projects/MbMbisBundle/Symfony/web/app_dev.php:0, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   2. Symfony\\Component\\HttpKernel\\Kernel->handle() /home/roland/projects/MbMbisBundle/Symfony/web/app_dev.php:25, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   3. Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel->handle() /home/roland/projects/MbMbisBundle/Symfony/app/bootstrap.php.cache:2248, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   4. Symfony\\Component\\HttpKernel\\HttpKernel->handle() /home/roland/projects/MbMbisBundle/Symfony/app/bootstrap.php.cache:2946, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   5. Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /home/roland/projects/MbMbisBundle/Symfony/app/bootstrap.php.cache:2817, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   6. call_user_func_array() /home/roland/projects/MbMbisBundle/Symfony/app/bootstrap.php.cache:2843, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   7. Mb\\MVibesEmailBundle\\Controller\\PromotionController->saveAction() /home/roland/projects/MbMbisBundle/Symfony/app/bootstrap.php.cache:2843, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   8. Mb\\MVibesEmailBundle\\Controller\\PromotionController->saveAttachment() /home/roland/projects/MbMbisBundle/Symfony/vendor/mb/mb-mvibesemail-bundle/Mb/MVibesEmailBundle/Controller/PromotionController.php:97, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP   9. Gregwar\\Image\\Image->save() /home/roland/projects/MbMbisBundle/Symfony/vendor/mb/mb-mvibesemail-bundle/Mb/MVibesEmailBundle/Controller/PromotionController.php:168, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP  10. Gregwar\\Image\\Image->init() /home/roland/projects/MbMbisBundle/Symfony/vendor/gregwar/image/Gregwar/Image/Image.php:580, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP  11. Gregwar\\Image\\Adapter\\Common->init() /home/roland/projects/MbMbisBundle/Symfony/vendor/gregwar/image/Gregwar/Image/Image.php:548, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP  12. Gregwar\\Image\\Adapter\\Common->loadFile() /home/roland/projects/MbMbisBundle/Symfony/vendor/gregwar/image/Gregwar/Image/Adapter/Common.php:127, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP  13. Gregwar\\Image\\Adapter\\GD->convertToTrueColor() /home/roland/projects/MbMbisBundle/Symfony/vendor/gregwar/image/Gregwar/Image/Adapter/Common.php:115, referer: http://mbis2.lo/app_dev.php/email/promotion/new
[Tue Feb 04 09:46:21 2014] [error] [client 192.168.56.1] PHP  14. imagecolorat() /home/roland/projects/MbMbisBundle/Symfony/vendor/gregwar/image/Gregwar/Image/Adapter/GD.php:424, referer: http://mbis2.lo/app_dev.php/email/promotion/new

Test image:

mshsl113454knight

rolandow avatar Feb 04 '14 08:02 rolandow

Hello, What's slow is converting the image to true colors (see https://github.com/Gregwar/Image/blob/master/Adapter/GD.php#L404)

If your server is running PHP 5.5, it should be faster because imagepalettetotruecolor was introduced, allowing to do it natively

Gregwar avatar Feb 06 '14 09:02 Gregwar