convert 是ImageMagick 里的一个工具,在处理webp格式的图片时候,版本低的时候,不支持webp,报错:convert: Not a JPEG file
来解决它:
下载了最新的 ImageMagick-7.1.1-15
执行:
./configure --with-webp=yes
完成后可以看到:
WEBP --with-webp=yes no
也就是现在运行的参数没有生效,是no
查看 config.log ,里面可以看到找不到libwebp.pc的报错
安装 libwebp-dev 这个东西
root@VM-0-14-ubuntu# apt install libwebp-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libwebp-dev
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 268 kB of archives.
After this operation, 929 kB of additional disk space will be used.
Get:1 http://mirrors.tencentyun.com/ubuntu bionic-security/main amd64 libwebp-dev amd64 0.6.1-2ubuntu0.18.04.2 [268 kB]
Fetched 268 kB in 0s (1,419 kB/s)
Selecting previously unselected package libwebp-dev:amd64.
(Reading database ... 112450 files and directories currently installed.)
Preparing to unpack .../libwebp-dev_0.6.1-2ubuntu0.18.04.2_amd64.deb ...
Unpacking libwebp-dev:amd64 (0.6.1-2ubuntu0.18.04.2) ...
Setting up libwebp-dev:amd64 (0.6.1-2ubuntu0.18.04.2) ...
安装完成,再找找看:
root@VM-0-14-ubuntu# updatedb
root@VM-0-14-ubuntu# locate libwebp.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/libwebp.pc
找到了。
那系统怎么找到这些库?你必须确保 pkgconfig 可以看到 libwebp.pc 这个文件
root@VM-0-14-ubuntu# pkg-config --list-all | grep webp
libwebpmux libwebpmux - Library for manipulating the WebP graphics format container
libwebp libwebp - Library for the WebP graphics format
libwebpdemux libwebpdemux - Library for parsing the WebP graphics format container
这次看到了,再试试configure吧:
./configure --with-webp=yes
make 和 make configure 后,记得 ldconfig /usr/local/lib
再看看convert是否支持:
# convert --version
Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 21298 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): freetype jng jpeg png webp x xml zlib
Compiler: gcc (7.5)
有了。