Gif not looping

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Intersekt
Posts: 4
Joined: 2011-08-08T10:38:15-07:00
Authentication code: 8675308

Gif not looping

Post by Intersekt »

Hello everyone,
I'm trying to create an animate GIF using imagick on PHP. My problem is that my gif loops only once.

Image

Code: Select all

<?php
	
	$im=new Imagick();
	$bg=new Imagick();
	
	for ($i=0; $i<10; $i++){
		$bg->readImage("./test/image_$i.gif");
	}	
	$im->addImage($bg);	
	$im->writeImages("result.gif", true);

?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gif not looping

Post by fmw42 »

In command line you would set a -delay for each image and at the end you would set -loop 0 so that it loops continuously.

I see setImageDelay at http://us3.php.net/manual/en/book.imagick.php but I cannot find anything like setImageLoop. But perhaps I have missed it. I am not an iMagick programmer.
Intersekt
Posts: 4
Joined: 2011-08-08T10:38:15-07:00
Authentication code: 8675308

Re: Gif not looping

Post by Intersekt »

Yes I was searching for a setloop option too but I didn't find any. I've used this script before and I never had any problem so I don't know if report this as bug or not.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Gif not looping

Post by fmw42 »

Intersekt wrote:Yes I was searching for a setloop option too but I didn't find any. I've used this script before and I never had any problem so I don't know if report this as bug or not.
Perhaps it is just missing from the docs. Try setImageLoop("0") just before the write and see what happens. Also use setImageDelay() before adding the frames to set the delay between frames.
Intersekt
Posts: 4
Joined: 2011-08-08T10:38:15-07:00
Authentication code: 8675308

Re: Gif not looping

Post by Intersekt »

Call to undefined method Imagick::setImageLoop()
I added the delay(0) but nothing changes
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Gif not looping

Post by magick »

Intersekt
Posts: 4
Joined: 2011-08-08T10:38:15-07:00
Authentication code: 8675308

Re: Gif not looping

Post by Intersekt »

Thank you very much ;)
Post Reply