imagick php 7.2 not setting webp format
Asked Answered
W

1

8

I have ImageMagick 6.7.8-9 and cwebp and dwebp (libwebp, libwebp-devel) installed and working as expected from the command line.

I have php7.2 installed from webtatic.

the problem I'm facing is that php imagick is not wrking with webp extension (other formats are working fine) here's what I get when I try Imagick: Fatal error: Uncaught ImagickException: Unable to set image format in .... : Imagick->setimageformat('webp')

please help me, I googled a lot, stackoverflow has nothing regarding this issue.. any clue, guidance, answer will be apreciated, thanks in advance

Wattle answered 13/3, 2018 at 12:16 Comment(2)
Run php -i | grep ImageMagick. Is WEBP listed under "supported formats"? If not, you may need to install Imagick from source.Oina
thanks for your answer, I did so, it is not listed. but the thing is it works just fine from the command line convert image.jpg image.webp sorry if I look a bit annoying, but why doesn't it work? besides can I uninstall imagemagick 6 and install imagemagick 7 without affecting php's imagick? (i read somewhere that I should do so)Wattle
R
7

Don't use Imagick->setimageformat('webp') use the following syntax instead:

$imagick = new \Imagick('/tmp/foo.jpg'); $imagick->writeImage('webp:/tmp/foo.webp');

That should do the trick for you ;-)

Rosalia answered 16/10, 2018 at 13:37 Comment(1)
i used this method and output file has webp format but it's contents is with jpeg file formatAinslee

© 2022 - 2024 — McMap. All rights reserved.