Page 1 of 1
PHP API and displaying animated gif's doesn't work?
Posted: 2008-06-27T23:02:26-07:00
by hotzenplotz
hi, using php5 5.2.0, imagemagick 6.4.2 and imagick api 2.1.1. I'm using the following code:
$im=new Imagick("image.ext");
header('Content-type: image/type');
echo $im;
for displaying a JPEG-file or PNG-file this works fine, also for GIFs, but not for animated GIFs. imagick seems to load only the first frame. with function readImage nothing is changed. so, what can I do?
nico
Re: PHP API and displaying animated gif's doesn't work?
Posted: 2008-06-29T03:30:56-07:00
by anthony
That is not the right way to export a image.
If you are using a API, which it looks like, you convert the image into a 'blob' that is the right format. If using command calls from PHP, you can have the command output the image in the format wanted using png:- or whatever.
Re: PHP API and displaying animated gif's doesn't work?
Posted: 2008-07-01T13:30:59-07:00
by hotzenplotz
ok, I understand, but after trying for a while, I don't get things to work with php-api. With
$image=get_file_contents("pic.gif");
header('Content...');
echo $image;
alls works fine, but not the imagick api. I tried
$image=new Imagick();
$image->readImage("pic.gif");
header('Content...');
echo $image->getImageBlob();
and tried also to add
foreach ($image as $frame)
$frame->cropImage($width, $height, 0, 0);
but nothing seems to work. Confusing, but
$content=file_get_contents("pic.gif");
$image=new Imagick();
$image->readImageBlob($content);
echo $image->getImageBlob();
doesn't work, too. All experiments show only the first frame of the gif.
Re: PHP API and displaying animated gif's doesn't work?
Posted: 2008-07-01T16:28:33-07:00
by anthony
You should be able to specify the output image format for the blob somehow!
$image=new Imagick();
$image->readImage("pic.gif");
header('Content...');
$image->writeimage("gif:-");
I think you should search and/or post in the PHP IM forum.
This is not my normal API of choice, and I don't use it regually.