WebP was officially supported on April 27, 2020: tada: [^ webp-official] So now you don't have to do the hassle of:
I managed to convert JPEG and PNG images to WebP format on a lollipop rental server. It is premised on the standard plan or higher (SSH connection is possible).
WebP conversion? ʻImagewebp` It's easy to use the function: thumbs up: If you think ...
Fatal error: Uncaught Error: Call to undefined function imagewebp()
Did not work. If you check with `phpinfo ()` ![lolipop-phpinfo-gd.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/617255/ef6cf73a-d685-a14d-af51-d727606969eb.png) It turns out that lollipops don't support WebP. [^ webp-support] [^ webp-support]: When I contacted support, I received a reply that there are no plans to support WebP at this time (March 26, 2019). ~~ I would like to expect it in the future. ~~ ## Build an environment that can be converted to WebP on your own `cwebp`Images can be converted to WebP format by using command line tools ([A new image format for the Web | WebP | Google Developers](https://developers.google.com/speed/webp)). In other words`cwebp`The solution is to make it available on the lollipop server. ### policy Copy the `cwebp` command line tools and required libraries built in a lollipop-like environment to the lollipop server. Since `make` and` gcc` cannot be used on the lollipop rental server ([Available command list --Lollipop](https://lolipop.jp/manual/user/ssh/#p-command)), the rental server It is impossible to build on. ### Build build environment Build an environment similar to a lollipop rental server with VirtualBox. The point is to match the version ** [glibc](https://www.gnu.org/software/libc/) **. [^ glibc] [^ glibc]: Try downloading [Precompiled WebP utilities](https://developers.google.com/speed/webp/download) and running it on a lollipop server, `` cwebp: /lib64/libc.so. 6: version `GLIBC_2.14'not found (required by cwebp) `` and you can see that it doesn't work. [^ glibc2] [^ glibc2]: You might think that changing the version of glibc on the rental server ... but it's not possible because many programs depend on glibc. If you force it, all commands will be invalidated and you will get stuck (Reference: [[Solved] relocation error: /lib64/libc.so.6: symbol _dl_starting_up Solution --Qiita](/ sachiotomita / items / ef29520c55fc168191d8)). #### Check glibc version of lollipop server On the rental server ```shell /lib64/libc.so*
When you execute
GNU C Library stable release version 2.12, by Roland McGrath et al.
The version is displayed as (it was 2.12 in my environment).
Build a CentOS 6 (64bit) environment with glibc version 2.12 with VirtualBox. Since the rental server is CentOS [^ server-spec], the OS also matches it.
The method of building the environment with VirtualBox is not described in detail here. To explain it quite roughly
It is a flow. I enabled and used SSH without a GUI.
[^ server-spec]: Server specifications-Lollipop [^ aria2-qiita]: Reference: [Use explosive downloader aria2, which is several times faster than curl and wget --Qiita](/ TokyoMickey / items / cb51805a19dcee416151)
Build with CentOS of VirtualBox. MostlyCompiling the Utilities | WebP | Google DevelopersIt is written in.
Without this, the input image cannot be read even if it is built.
sudo yum install libjpeg-devel libpng-devel
libwebp-1.0.3.tar.gz from downloads list and extract it below
tar xvzf libwebp-1.0.3.tar.gz
Considering the trouble of uploading to the rental server later, install it in your home directory (
~ / bin / libwebp-1.0.3).
cd libwebp-1.0.3 ./configure --prefix=$HOME/bin/libwebp-1.0.3 make make install
Copy the following files to the home directory of the rental server.
|Local (VirtualBox)||Rental Server|
Create a symbolic link for your library.
cd ~/usr/lib ln -s libwebp.so.7.1.0 libwebp.so.7 ln -s libwebpdemux.so.2.0.6 libwebpdemux.so.2
Pass the path so that you can find the
cwebp and the libraries it uses.
cd ~ vi .bash_profile
Enter the insert mode with the ʻInsert` key and add the following contents.
export PATH=~/usr/bin:$PATH export LD_LIBRARY_PATH=~/usr/lib:$LD_LIBRARY_PATH
After editing, press the ʻEsc
key to enter command mode, press: wq
to save and exit. By reloading.bash_profile` with the following command, the path will be in the state. From now on, if you log in with SSH, your pass will be passed automatically.
If you try running
cwebp and the display looks like the one below, it's OK.
Usage: cwebp [options] -q quality input.png -o output.webp where quality is between 0 (poor) to 100 (very good). Typical value is around 80. Try -longhelp for an exhaustive list of advanced options.
If you get an error that the library cannot be found, you can copy the library to the rental server by referring to
~ / bin / libwebp-1.0.3 / lib / in the local environment.
Please note that you need to set environment variables as well as
~ / .bash_profile when using from PHP. Specify the environment variable with the absolute path from the root (path like
/ home / users / ..., you can check with the
pwd command) instead of
~ / bin / ....