Converting image to webp with ImageMagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dal77
Posts: 1
Joined: 2016-10-23T03:52:41-07:00
Authentication code: 1151

Converting image to webp with ImageMagick

Post by dal77 »

I am trying to to convert a jpg image to webp in a php script that uses Imagick, but it fails to recognise the webp format. I have installed the latest version of ImageMagick from source, libwebp-dev and php-imagick. I cannot figure out what I am missing.

Code: Select all

$im = new Imagick('$src');
$im->resizeImage($width,$height,Imagick::FILTER_CATROM , 1,TRUE );
$im->setImageFormat( "webp" );

PHP Fatal error:  Uncaught ImagickException: Unable to set image format in /ImageMagick-7.0.3-4/test.php:15
Stack trace:
#0 /ImageMagick-7.0.3-4/test.php(15): Imagick->setimageformat('webp')
#1 {main}

Code: Select all

convert -version
Version: ImageMagick 7.0.3-4 Q16 x86_64 2016-10-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): jbig jpeg tiff webp

Code: Select all

phpinfo()
imagick
imagick module => enabled
imagick module version => 3.4.2
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.8.9-9 Q16 x86_64 2016-04-18 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01 http://www.imagemagick.org
ImageMagick copyright => Copyright (C) 1999-2014 ImageMagick Studio LLC
ImageMagick release date => 2016-06-01
ImageMagick number of supported formats: => 215
ImageMagick supported formats => 3FR, AAI, AI, ART, ARW, AVI, AVS, BGR, BGRA, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FITS, FRACTAL, FTS, G3, GIF, GIF87, GRADIENT, GRAY, GROUP4, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, ICON, INFO, INLINE, IPL, ISOBRL, JBG, JBIG, JNG, JNX, JPEG, JPG, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV
I have noted that WEBP is missing from the list of supported formats, but I don't understand why.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting image to webp with ImageMagick

Post by snibgo »

dal77 wrote:Imagick compiled with ImageMagick version => ImageMagick 6.8.9-9
As you are using Imagick, the question is whether the ImageMagick library it uses has been built with webp.

You have another installatation, 7.0.3-4 with webp, but that isn't relevant.
snibgo's IM pages: im.snibgo.com
Post Reply