2

I convert animated gif to webp but the webp picture is not animated.

Did I miss a step? I don't find in the documentation.

my code:

//GD $image = imagecreatefromgif("./mypics.gif"); imagepalettetotruecolor($image); imagewebp($image, "./image.webp"); //Imagick $img = new \Imagick("./mypics.gif"); $img->stripImage(); $img->setImageFormat("webp"); $img->setImageAlphaChannel(\imagick::ALPHACHANNEL_ACTIVATE); $img->setBackgroundColor(new \ImagickPixel('transparent')); $img->writeImage("./image.webp"); 

2 Answers 2

4

php-vips supports animated web. For example:

// n=-1 means load all pages // sequential access means decode pixels on demand $image = Vips\Image::newFromFile('something.gif', [ 'n' => -1, 'access' => 'sequential' ]); $image->writeToFile('something.webp'); 
Sign up to request clarification or add additional context in comments.

Comments

2

GD does not support animated WebP. Imagemagick does, but only since relatively recent version 7.0.8-68 and if compiled with libwebp.

You either need to install latest imagemagick with webp support, or use some other external tool, like gif2webp.

1 Comment

I installed imagemagick 7.0.10-24 and the webp are animated. For the moment I'm executing a command with the exec() function from PHP, because the php-imagick package uses a version that doesn't support animated webp.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.