Page 1 of 1

How to add webp support to ImageMagick on Ubuntu?

Posted: 2018-09-30T06:55:37-07:00
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?

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

Posted: 2018-09-30T07:09:17-07:00
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.

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

Posted: 2018-09-30T07:27:15-07:00
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?

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

Posted: 2018-09-30T07:28:55-07:00
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"

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

Posted: 2018-09-30T08:16:26-07:00
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.

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

Posted: 2018-09-30T08:21:46-07:00
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.

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

Posted: 2018-09-30T08:46:33-07:00
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.

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

Posted: 2018-09-30T10:01:18-07:00
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;"/>

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

Posted: 2018-09-30T12:22:48-07:00
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?

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

Posted: 2018-09-30T12:44:42-07:00
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".

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

Posted: 2018-10-01T00:14:43-07:00
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? :)