xparq / AnimGif

PHP class to create an animated GIF from multiple images
89 stars 24 forks source link

Not able to sent gif to browser #2

Closed deepak-trimantra closed 6 years ago

deepak-trimantra commented 7 years ago

Hello,

I tried this library. This one creates a animated gif if i use save(); but i want to display gif in browser

$anim->create( "img/", array( 100 ) )->save( "anim.gif" ); $gif = $anim->get(); header( 'Content-type: image/gif' ); echo $gif; exit;

but this do not show gif in the browser, if i open it in firefox browser it shows 'cannot be displayed because it contains errors'.

AkashKrx commented 7 years ago

I am having same issue but it shows 502 Bad Gateway

deepak-trimantra commented 7 years ago

In create passing third parameter solved my issue e.g. $anim->create( "img/", array( 100 ), 1)->save( "anim.gif" );

ghost commented 7 years ago

Same problem here, using PHP 7. Displaying the animated GIF in browser results in 'cannot be displayed because it contains errors'. header("Content-type: image/$ext"); //$ext is 'png or gif' if ($ext === 'png') { ... } else if ($ext === 'gif') { $frames = $imagesArray; //array of images, created with 'imagecreatedfromgif' $durations = array(); //duration array for 10 secs in 1/100ms for ($i = 0; $i < $imagesCount; $i++) { //$imagesCount is $imagesArray length array_push($durations, 1000); } $anim = new \GifCreator\AnimGif(); $anim->create($frames, $durations, 0); $gif = $anim->get(); echo $gif; exit; } Previously runnig PHP 5.6 was running fine. Only change then was adding the backslash before GifCreator in PHP 7.

ghost commented 7 years ago

Anyone a suggestion? I am now using PHP 7.0.13 and still the same error message displaying. Looked through the code with NetBeans and PHP 7 info markup and no errors found. But it started to happen right after the code update on 7th March.