'Cant save webp format with imagick

Im developing a panel in which Im uploading a jpg, it copies it, resizes it, saves another jpg and now I want also to be able to create a copy but using webp extension.

Ive checked everywhere and couldnt find anyone with the same problem. Im running cPanel on CentOS cPanel > Version: ImageMagick 6.9.10-68 Q16 x86_64 2020-04-01

$imagick = new \Imagick($targetJpg); 
$imagick->writeImage('webp:'.$targetWebp);

I was getting this error

Fatal error: Uncaught ImagickException: delegate failed `'cwebp' -quiet %Q '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1928 in /...dirs.../pic-upload.php:108 Stack trace: #0 /...dirs.../pic-upload.php(108): Imagick->writeimage('webp:../images/...') #1

=========================================================

In my local machine, OSX, using Mamp, that was solved with @MarkSetchell help.

On OSX > Terminal type: cwebp -version webp 1.1.0

type: type cwebp cwebp is hashed (/usr/local/bin/cwebp)

Marks solution > Worked! :) On macOS, your cwebp seems to be the homebrew one in /usr/local/bin, so I would suggest you find your Imagick config file called delegates.xml and edit it so that where it says 'cwebp' -quiet -q %Q '%I'... it becomes '/usr/local/bin/cwebp' -quiet -q...

=========================================================

In CentOS cPanel

Neither cwebp or dwebp was installed. This was due to the package libwebp-tools not being installed.

I installed them and checked - results: [root@server:/]$ whereis cwebp cwebp: /usr/bin/cwebp /usr/share/man/man1/cwebp.1.gz [root@server:/]$ whereis dwebp dwebp: /usr/bin/dwebp /usr/share/man/man1/dwebp.1.gz

Everything working now! Hope this is useful for someone else. Thanks for the Mark and Chris for the help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source