Анимированный GIF с Gifencoderclass.php, источник не GIF

Я только что нашел библиотеку php для создания анимированных GIF-файлов.
Я думаю, что отредактировал пример кода правильно, но я получаю ошибку GIFEncoder V2.05: 0 Source is not a GIF image!,

Кто-нибудь, кто использовал этот класс php и может мне помочь?
Ниже приведен код, который я использовал, я закомментировал пример кода.

<?php

include "GIFEncoder.class.php";
/*
Build a frames array from sources...

if ( $dh = opendir ( "frames/" ) ) {
while ( false !== ( $dat = readdir ( $dh ) ) ) {
if ( $dat != "." && $dat != ".." ) {
$frames [ ] = "frames/$dat";
$framed [ ] = 5;
}
}
closedir ( $dh );
}
*/
$frames = array("http://www.hoppvader.nu/weatherpics/Windsock1/windsock-10.gif","http://www.hoppvader.nu/weatherpics/Windsock1/windsock-20.gif","http://www.hoppvader.nu/weatherpics/Windsock1/windsock-30.gif");
$framed = array(40, 80, 40);
/*
GIFEncoder constructor:
=======================

image_stream = new GIFEncoder   (
URL or Binary data  'Sources'
int                 'Delay times'
int                 'Animation loops'
int                 'Disposal'
int                 'Transparent red, green, blue colors'
int                 'Source type'
);
*/
$gif = new GIFEncoder   (
$frames,
$framed,
0,
2,
0, 0, 0,
"url");
/*
Possibles outputs:
==================

Output as GIF for browsers :
- Header ( 'Content-type:image/gif' );
Output as GIF for browsers with filename:
- Header ( 'Content-disposition:Attachment;filename=myanimation.gif');
Output as file to store into a specified file:
- FWrite ( FOpen ( "myanimation.gif", "wb" ), $gif->GetAnimation ( ) );
*/
Header ( 'Content-type:image/gif' );
echo    $gif->GetAnimation ( );
?>

1

Решение

Вместо этого вы должны использовать Gifcreator:

https://github.com/Sybio/GifCreator

<?php
include "GifCreator.php";

// create an array with images
$frames =  array(imagecreatefromjpeg("pic1.jpg"),
imagecreatefromjpeg("pic2.jpg"),
imagecreatefromjpeg("pic3.jpg"));

// the time each image should be visible in ms
$time = array(20,20,20);

// create the gif-image
$gc = new \GifCreator\GifCreator();
$gc->create($frames, $durations, 0);

$gifBinary = $gc->getGif();

header('Content-type: image/gif');
header('Content-Disposition: filename="GIF-image"');

//echo the GIF-image
echo $gifBinary;

?>

Я не использовал GIFencoder, но я использовал GIFcreator, поэтому я предложил это.

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector