Please help: Memory allocation error with Magick PHP and exec()
Posted: 2016-10-04T08:14:42-07:00
Hello,
thanks for reading this, I need some help: I wrote a PHP-script that generates animated GIFs from a range of JPGs. The script worked fine until my provider updated ImageMagick and applied some security patches to the server.
Now the PHP-script doesn't finish its work anymore. Although I am able to setup the Imagick-Object (the GIF) with all frames needed (about 32), the "WriteImages"-funtion fails as soon as I have more than six JPGs added to the animated GIF. The JPGs are sized 300x400 Pixel.
Since I need the script, I tried to generate the GIF without the PHP-class but with exec(). Same issue there, probably the class uses exec() internally?
However, my provider (ALFAHOSTING) said that this is either an error of Imagick or the "system", so they cannot do anything about it. This is really annyoing for me, I am working a lot with animated GIFs.
I wonder if anyone has an idea of what is going wrong and what else I could try?
Below is the script I used for testing and this is the address where it is hosted: http://makerlove.zfmobil.de/_te/width300/test_exec.php
Thanks a lot! Martin.
thanks for reading this, I need some help: I wrote a PHP-script that generates animated GIFs from a range of JPGs. The script worked fine until my provider updated ImageMagick and applied some security patches to the server.
Now the PHP-script doesn't finish its work anymore. Although I am able to setup the Imagick-Object (the GIF) with all frames needed (about 32), the "WriteImages"-funtion fails as soon as I have more than six JPGs added to the animated GIF. The JPGs are sized 300x400 Pixel.
Since I need the script, I tried to generate the GIF without the PHP-class but with exec(). Same issue there, probably the class uses exec() internally?
However, my provider (ALFAHOSTING) said that this is either an error of Imagick or the "system", so they cannot do anything about it. This is really annyoing for me, I am working a lot with animated GIFs.
I wonder if anyone has an idea of what is going wrong and what else I could try?
Below is the script I used for testing and this is the address where it is hosted: http://makerlove.zfmobil.de/_te/width300/test_exec.php
Thanks a lot! Martin.
Code: Select all
<?php
echo "<pre>";
phpinfo(INFO_GENERAL);
echo "<br>";
echo "<br>";
//system("type convert");
echo "IMAGICK VERSION:<br>";
exec("/usr/bin/convert -version 2>&1",$output,$return_value);
var_dump($output);
echo "----------------------------------------<br><br>";
array_map('unlink', glob("*.gif")); // delete all GIFs in the folder
// Try to create animated GIFS with exec
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg -loop 0 animation1.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg -loop 0 animation1.gif 2>&1",$output,$return_value);
var_dump($output);
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg 001.jpg -loop 0 animation2.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg 001.jpg -loop 0 animation2.gif 2>&1",$output,$return_value);
var_dump($output);
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg -loop 0 animation3.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg -loop 0 animation3.gif 2>&1",$output,$return_value);
var_dump($output);
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg -loop 0 animation4.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg -loop 0 animation4.gif 2>&1",$output,$return_value);
var_dump($output);
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg 004.jpg -loop 0 animation5.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg 004.jpg -loop 0 animation5.gif 2>&1",$output,$return_value);
var_dump($output);
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg 004.jpg 005.jpg -loop 0 animation6.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg 004.jpg 005.jpg -loop 0 animation6.gif 2>&1",$output,$return_value);
var_dump($output);
$output = "";
echo "<br>exec /usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg 004.jpg 005.jpg 006.jpg -loop 0 animation7.gif RESULT:<br>";
exec("/usr/bin/convert -delay 1x1 000.jpg 001.jpg 002.jpg 003.jpg 004.jpg 005.jpg 006.jpg -loop 0 animation7.gif 2>&1",$output,$return_value);
var_dump($output);
echo "<br>";
echo "<br>";
// Try to create animated GIFS with exec
$GIF = new Imagick();
$GIF->setFormat("gif");
$frame = new Imagick();
for($i=0;$i<7;$i++)
{
$fileJPG = sprintf('%03d',$i).".jpg";
$frame->readImage($fileJPG);
$frame->setImageDelay(20);
$GIF->addImage($frame);
$frame->destroy();
}
$GIF->writeImages("output.gif",true);
echo "</pre>";
/*exec("/usr/bin/convert -delay 1x1 000.jpg -delay 1x6 001.jpg 002.jpg 003.jpg 004.jpg 005.jpg 006.jpg -delay 1x1 007.jpg -delay 1x6 008.jpg 009.jpg 010.jpg 011.jpg 012.jpg 013.jpg 014.jpg -delay 1x1 015.jpg -delay 1x6 014.jpg 013.jpg 012.jpg 011.jpg 010.jpg 009.jpg 008.jpg -delay 1x1 007.jpg -delay 1x6 006.jpg 005.jpg 004.jpg 003.jpg 002.jpg 001.jpg -loop 0 animation.gif");
*/
?>