How to add webp support to ImageMagick on Ubuntu?

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
netdjw
Posts: 6
Joined: 2018-09-30T06:47:04-07:00
Authentication code: 1152

How to add webp support to ImageMagick on Ubuntu?

Post by netdjw »

Hi there!

I want to add webp support to my ImageMagick on Ubuntu Linux, and the "make install" is not a good way for me, if I want to keep easily maintainable my system. So I'm looking a way what is working with "apt-get install" and/or editing config files.

I installed the webp and libwebp-dev packages and it's dependencies.

After this I checked the /etc/ImageMagick/delegates.xml but nothing found about webp, so I insert this line:

Code: Select all

<delegate decode="webp" command="&quot;dwebp&quot; -pam &quot;%i&quot; -o &quot;%o&quot;"/>
...but not working. I get this message:

Code: Select all

Image::Magick error: Exception 420: no encode delegate for this image format '2.webp' @ error/constitute.c/WriteImage/1209 (2.webp)
How can I solve this issue?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add webp support to ImageMagick on Ubuntu?

Post by snibgo »

What version of IM? I'll assume v7.something.

What command did you give?

What does "magick -list delegate" say?

Your delegates.xml has a line to decode webp, but the error message says IM can't encode the file.
snibgo's IM pages: im.snibgo.com
netdjw
Posts: 6
Joined: 2018-09-30T06:47:04-07:00
Authentication code: 1152

Re: How to add webp support to ImageMagick on Ubuntu?

Post by netdjw »

snibgo wrote: 2018-09-30T07:09:17-07:00 What version of IM? I'll assume v7.something.

Code: Select all

convert -version
Version: ImageMagick 6.7.7-10 2017-07-31 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
snibgo wrote: 2018-09-30T07:09:17-07:00 What command did you give?
I'm using ImageMagick under perl (v5.18.2)
snibgo wrote: 2018-09-30T07:09:17-07:00 What does "magick -list delegate" say?

Code: Select all

magick: command not found
snibgo wrote: 2018-09-30T07:09:17-07:00 Your delegates.xml has a line to decode webp, but the error message says IM can't encode the file.
Okay, but I don't understand what this mean... What I need to do to IM can encode the file?
netdjw
Posts: 6
Joined: 2018-09-30T06:47:04-07:00
Authentication code: 1152

Re: How to add webp support to ImageMagick on Ubuntu?

Post by netdjw »

snibgo wrote: 2018-09-30T07:09:17-07:00 What does "magick -list delegate" say?
I don't have "magick" command, but "convert" says this:

Code: Select all

# convert -list delegate

Path: /etc/ImageMagick/delegates.xml

Delegate                Command
-------------------------------------------------------------------------------
    blender =>          "blender" -b "%i" -F PNG -o "%o""\n"convert" -concatenate "%o*.png" "%o"
        cdr =>          "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
        cgm =>          "ralcgm" -d ps -oC < "%i" > "%o" 2> "%Z"
 dng:decode =>          "ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i"
        dot =>          "dot" -Tsvg "%i" -o "%o"
        dvi =>          "dvips" -q -o "%o" "%i"
        eps<=>pdf       "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
        eps<=>ps        "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=nodevice" "-sOutputFile=%o" "-f%i"
        fig =>          "fig2dev" -L ps "%i" "%o"
        hpg =>          "hp2xx" -q -m eps -f `basename "%o"` "%i";     mv -f `basename "%o"` "%o"
       hpgl =>          "if [ -e hp2xx -o -e /usr/bin/hp2xx ]; then     hp2xx -q -m eps -f `basename "%o"` "%i";     mv -f `basename "%o"` "%o";   else     echo "You need to install hp2xx to use HPGL files with ImageMagick.";     exit 1;   fi"
        htm =>          "html2ps" -U -o "%o" "%i"
       html =>          "html2ps" -U -o "%o" "%i"
      https =>          "curl" -s -k -o "%o" "https:%F"
       ilbm =>          "ilbmtoppm" "%i" > "%o"
        man =>          "groff" -man -Tps "%i" > "%o"
       miff<= show      "/usr/bin/display" -delay 0 -window-group %[group] -title "%l " "ephemeral:%i"
mpeg:decode =>          "ffmpeg" -v -1 -i "%i" -vframes %S -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"
        pdf<=>eps       "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
        pdf<=>ps        "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=nodevice" "-sOutputFile=%o" "-f%i"
        pnm<= ilbm      "ppmtoilbm" -24if "%i" > "%o"
        pov =>          "povray" "+i%i" -D0 "+o%o" +fn%q +w%w +h%h +a -q9 "-kfi%s" "-kff%n";"convert" -concatenate "%o*.png" "%o"
         ps<=>eps       "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
         ps<=>pdf       "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
         ps<= print     "lpr "%i"
       rgba<= rle       "rawtorle" -o "%o" -v "%i"
       scan =>          "scanimage" -d "%i" > "%o"
      scanx =>          "scanimage" > "%o"
      shtml =>          "html2ps" -U -o "%o" "%i"
        sid =>          "mrsidgeodecode" -if sid -i "%i" -of tif -o "%o" > "%u"
        svg =>          "rsvg-convert" -o "%o" "%i"
       tiff<= launch    "gimp" "%i"
        txt<=>ps        "enscript" -o "%o" "%i"
       webp =>          "dwebp" -pam "%i" -o "%o"
        wmf =>          "wmf2eps" -o "%o" "%i"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add webp support to ImageMagick on Ubuntu?

Post by snibgo »

IM v6.7.7-10 is massively old. Perhaps your version is patched.

Okay, you are using IM under perl, but what operation are you asking IM to do?

IM v6 uses "convert", and IM v7 uses "magick". That's why I asked what version IM.

Your "convert -list delegate" shows:
webp => "dwebp" -pam "%i" -o "%o"
... so IM will run dwepb when it is try to read (ie "decode") a webp file. But nothing is shown for writing (ie "encode") to webp. And that is what the error message is complaining about.

You need to provide an "encode" command.
snibgo's IM pages: im.snibgo.com
netdjw
Posts: 6
Joined: 2018-09-30T06:47:04-07:00
Authentication code: 1152

Re: How to add webp support to ImageMagick on Ubuntu?

Post by netdjw »

I just want to save a JPG file into a WEBP file. Nothing special.

Can you help me create an encode command? I'm absolutely lamer for this.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add webp support to ImageMagick on Ubuntu?

Post by snibgo »

"dwebp -h" tells us this program decodes (ie reads) webp files, and converts to another format.

A quick search in the same directory of my computer finds "cwebp" which works in the other direction. "cwebp -h" gives usage.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to add webp support to ImageMagick on Ubuntu?

Post by fmw42 »

Linux versions are not always updated when a patch in included? What is the date associated with your version. Use convert -version on IM 6 and magick -version on IM 7. It will be next to the version number. I do not use WEBP but in my delegates.xml file on IM 6.9.10.12 Q16 Mac OSX Sierra, there is an entry for it:

Code: Select all

  <delegate decode="webp" command="&quot;dwebp&quot; -pam &quot;%i&quot; -o &quot;%o&quot;"/>
netdjw
Posts: 6
Joined: 2018-09-30T06:47:04-07:00
Authentication code: 1152

Re: How to add webp support to ImageMagick on Ubuntu?

Post by netdjw »

fmw42 wrote: 2018-09-30T10:01:18-07:00 Linux versions are not always updated when a patch in included? What is the date associated with your version. Use convert -version on IM 6 and magick -version on IM 7. It will be next to the version number. I do not use WEBP but in my delegates.xml file on IM 6.9.10.12 Q16 Mac OSX Sierra, there is an entry for it:

Code: Select all

  <delegate decode="webp" command="&quot;dwebp&quot; -pam &quot;%i&quot; -o &quot;%o&quot;"/>
I write it into my delegates.xml, but this isn't solved the problem. But here is something new:

I tried this in the delegates.xml:

Code: Select all

<delegate encode="webp" command="cwebp -quiet &quot;%i&quot; -o &quot;%o&quot;"/>
Now I have this error message:

Code: Select all

Image::Magick error: Exception 415: delegate failed `cwebp -quiet "%i" -o "%o"' @ error/delegate.c/InvokeDelegate/1065 (2.webp)
And another one: if I run this command, it works perfectly fine:

Code: Select all

cwebp -quiet "1.jpg" -o "2.webp"
The wired is this command is same what's in the delegates.xml ... I don't understand why not working... any idea?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to add webp support to ImageMagick on Ubuntu?

Post by snibgo »

Adding your line to delegates.xml works fine for me.

IM is clearly trying to run your delegate, but failing. Perhaps you need special privileges from perl. Does perl run the command from your account, with your normal privileges?

I suggest you remove "-quiet" from your delegate, while testing. If you can access the IM command, adding "-verbose" may give a clue. Failing that, try "-debug all".
snibgo's IM pages: im.snibgo.com
netdjw
Posts: 6
Joined: 2018-09-30T06:47:04-07:00
Authentication code: 1152

Re: How to add webp support to ImageMagick on Ubuntu?

Post by netdjw »

snibgo wrote: 2018-09-30T12:44:42-07:00 IM is clearly trying to run your delegate, but failing. Perhaps you need special privileges from perl. Does perl run the command from your account, with your normal privileges?
I treied to run as root. Perl run under root privileges in this case.
snibgo wrote: 2018-09-30T12:44:42-07:00 I suggest you remove "-quiet" from your delegate, while testing. If you can access the IM command, adding "-verbose" may give a clue. Failing that, try "-debug all".
I removed "-quiet" and get this:

Code: Select all

webp:
Error! Could not process file /tmp/magick-WQfRMvi9
Error! Cannot read input picture file '/tmp/magick-WQfRMvi9'
Image::Magick error: Exception 415: delegate failed `"cwebp" "%i" -o "%o"' @ error/delegate.c/InvokeDelegate/1065 (2.webp)
I think perl read the JPG file and dump it into the /tmp directory (it has rwx permission on directory), but can't read it. I checked the file in /tmp and wasn't there. Maybe it is created but I can't catch is.

Any other idea? :)
Post Reply