Конвертировать в webp linux

How to Convert Images to WebP Format in Linux

One of the numerous best practices you will hear of, for optimizing your web-site performance is using compressed images. In this article, we will share with you a new image format called webp for creating compressed and quality images for the web.

WebP is a relatively new, open source image format that offers exceptional lossless and lossy compression for images on the web, designed by Google. To use it, you need to download pre-compiled utilities for Linux, Windows and Mac OS X.

With this modern image format, webmasters and web developers can create smaller, richer images that make the web faster.

How to Install WebP Tool in Linux

Thankfully, the webp package is present in the Ubuntu official repositories, you can install it using the APT package manager as shown.

On other Linux distributions, start by downloading the webp package from Googles repository using the wget command as follows.

$ wget -c https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.1-linux-x86-32.tar.gz

Now extract the archive file and move into the extracted package directory as follows.

$ tar -xvf libwebp-0.6.1-linux-x86-32.tar.gz $ cd libwebp-0.6.1-linux-x86-32/ $ cd bin/ $ ls

Webp Packages

As you can see from the above screen shot, the package contains a precompiled library (libwebp) for adding webp encoding or decoding to your programs and various webp utilities listed below.

  • anim_diff – tool to display the difference between animation images.
  • anim_dump – tool to dump the difference between animation images.
  • cwebp – webp encoder tool.
  • dwebp – webp decoder tool.
  • gif2webp – tool for converting GIF images to webp.
  • img2webp – tools for converting a sequence of images into an animated webp file.
  • vwebp – webp file viewer.
  • webpinfo – used to view info about a webp image file.
  • webpmux – webp muxing tool.

To convert an image to webp, you can use the cwebp tool, where the -q switch defines the output quality and -o specifies the output file.

$ cwebp -q 60 Cute-Baby-Girl.png -o Cute-Baby-Girl.webp OR $ ./cwebp -q 60 Cute-Baby-Girl.png -o Cute-Baby-Girl.webp

Covert Image to WebP Format

You can view the converted webp image using the vwebp tool.

View WebP Format Image

You can see all options for any of the tools above by running them without any arguments or using the -longhelp flag, for example.

Last but not least, if you want to run the above programs without typing their absolute paths, add the directory ~/libwebp-0.6.1-linux-x86-32/bin to your PATH environmental variable in your ~/.bashrc file.

Читайте также:  Операционные системы linux какие бывают

Add the line below towards the end of the file.

export PATH=$PATH:~/libwebp-0.6.1-linux-x86-32/bin

Save the file and exit. Then open a new terminal window and you should be able to run all webp programs like any other system commands.

Also check out these useful related articles:

WebP is just one of the many products coming out of Google’s continuous efforts towards making the web faster. Remember to share you thoughts concerning this new image format for the web, via the feedback form below.

Источник

Как конвертировать изображения в Webp в Linux

Изображения Webp — это изображения высокого качества со сжатием, используемые для отображения изображений на веб-сайтах и в веб-приложениях. Поскольку размер их файлов намного меньше, чем JPG или PNG, они быстро загружаются, делают ваш сайт быстрее и экономят пропускную способность. Webp — это формат изображений с открытым исходным кодом, созданный Google и быстро завоевавший популярность среди разработчиков и веб-мастеров. В большинстве случаев люди просто конвертируют существующие изображения в webp, вместо того чтобы создавать их с нуля. В этой статье мы узнаем, как конвертировать изображения в webp в Linux.

Как конвертировать изображения в Webp в Linux

Для нашей цели мы будем использовать библиотеку webp. Существует множество инструментов и библиотек webp, доступных для различных дистрибутивов Linux. Откройте терминал и выполните следующую команду для установки инструмента webp в Ubuntu/Debian.

sudo apt install webp

После установки инструмента webp в систему вы можете легко конвертировать изображения в формат webp с помощью следующей команды. Мы используем опцию -q для определения качества вывода и -o для определения имени выходного файла.

webp -q 60 test.png -o test.webp

Вы также можете собрать инструмент из исходников. Сначала загрузите его исходный текст из репозиториев Google.

wget -c https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.3.0.tar.gz

Затем выполните следующие команды, чтобы распаковать скачанный tarball.

tar -xvf libwebp-1.3.0.tar.gz cd libwebp-1.3.0/ cd bin/ ls

Приведенная выше команда ls выведет на экран следующие имена файлов. Все они призваны помочь вам работать с webp-изображениями в различных условиях.

  • anim_diff — инструмент для отображения разницы между анимационными изображениями.
  • anim_dump — инструмент для сброса разницы между анимационными изображениями.
  • cwebp — инструмент для кодирования webp.
  • dwebp — инструмент декодера webp.
  • gif2webp — инструмент для преобразования изображений GIF в webp.
  • img2webp — инструмент для преобразования последовательности изображений в анимированный webp-файл.
  • vwebp — программа для просмотра файлов webp.
  • webpinfo — используется для просмотра информации о файле изображения webp.
  • webpmux — инструмент для мультиплексирования webp.

Из всех вышеперечисленных инструментов мы будем использовать cwebp для преобразования изображения в формат webp. Мы используем опцию -q для определения качества вывода и -o для определения имени выходного файла. Вот пример команды для преобразования изображения в формат webp.

cwebp -q 60 test.png -o test.webp
./cwebp -q 60 test.png -o test.webp

После преобразования изображения в формат .webp вы можете легко просмотреть его с помощью программы просмотра vwebp.

Если вы хотите просмотреть список доступных опций для каждого из этих инструментов, просто запустите их без каких-либо опций или с опцией -longhelp.

Наконец, если вы не хотите указывать полный путь к этим командам, а хотите напрямую вызывать их из любой точки вашей системы, добавьте расположение ~/libwebp-0.6.1-linux-x86-32/bin в переменную среды PATH в вашем файле ~/.bashrc.

Читайте также:  Nvidia ion driver linux

Добавьте следующую строку в конец вышеуказанного файла.

export PATH=$PATH:~/libwebp-1.3.0/bin

Сохраните и закройте файл. Перезагрузите файл bashrc, чтобы применить изменения.

Теперь вы должны иметь возможность запускать все инструменты webp в папке ~/libwebp-0.6.1-linux-x86-32/bin без указания их полных путей.

В этой статье мы узнали, как легко конвертировать изображения в формат webp в Linux с помощью инструмента webp. Вы можете использовать этот инструмент для конвертирования изображений других форматов в webp. Если вы хотите конвертировать gif в webp, то вам может понадобиться инструмент gif2webp, указанный выше.

Похожие записи:

Источник

Convert PNG Images to WebP on Linux (With Commands)

The WebP image format is great at compressing photos to incredibly small file sizes. This makes it an ideal format for images on websites, just as its name would imply. Outside of web hosting, the PNG image format is much more popular and better suited to archiving.

In this tutorial, you’ll see how to convert WebP images to PNG with Linux commands. You’ll also see how to convert images into WebP, in case you plan to upload photos somewhere and want the smaller file size for your web visitors.

Install dwebp and cwebp on Linux

The dwebp command is used to convert photos from WebP to PNG. Conversely, cwebp is used to convert PNG images into WebP files.

You can install these tools with your Linux distro’s package manager by using the appropriate command below.

Ubuntu, Debian, and Linux Mint:

$ sudo dnf install libwebp-tools

Convert PNG images to WebP

Example 1. Use the cwebp tool to encode PNG images into WebP. All you need to do is specify the name of your PNG file, the -o (output) option, and the name of your new WebP file.

$ cwebp image.png -o image.webp

Example 2. Use the -q option to control the quality level. This can help you achieve a lower file size while sacrificing some quality in your image. A quality level of 80-85% generally gives acceptable results.

$ cwebp -q 85 image.png -o image.webp

Example 3. It’s also a good idea to use the -mt (multi-threading) option, which will better utilize your system’s CPU and convert the images more quickly.

$ cwebp -q 85 -mt image.png -o image.webp

Example 4. If you have a lot of PNG photos to convert, you can use a Bash for loop to bulk convert hundreds or thousands of PNG photos to WebP at once.

$ for f in *.png; do cwebp -q 85 -mt $f -o $.webp; done

Example 5. If you have PNG files scattered throughout subdirectories, you can use the find command to traverse subdirectories and convert every .PNG (or .png) file that it finds.

$ find . -iname "*.png" -exec cwebp -q 85 -mt <> -o <>.webp \;

Convert WebP images to PNG

Example 1. Use the dwebp tool to decode WebP images into PNG. All you need to do is specify the name of your WebP file, the -o (output) option, and the name of your new PNG file.

$ dwebp image.webp -o image.png

Example 2. If you have a lot of WebP photos to convert, you can use a Bash for loop to bulk convert hundreds or thousands of WebP photos at once.

$ for f in *.webp; do dwebp $f -o $f.png; done

2 thoughts on “Convert PNG Images to WebP on Linux (With Commands)”

Example 4: you may want to remove the png extension for f in *.png; do cwebp -q 85 -mt $f -o $.webp; done

Читайте также:  Установить локальный сервер linux

Источник

Easily Convert Images to WebP on Linux and macOS

WebP is a modern, open source, image format that provides superior lossless and lossy compression ( as well as animation and alpha transparency ) for images on the web.

There are a lot of online tools that will allow you to convert your images but, why upload your images on a random server when you can easily convert them right on your computer?

Installing libwebp on Linux

  • Arch and derivates: sudo pacman -S libwebp
  • Ubuntu and derivates: sudo apt install webp
  • Fedora: sudo dnf install libwebp-tools

Installing libwebp on macOS

To install the necessary tools on macOS, you first need to have Homebrew installed.

Once Homebrew is up and running, you can install libwebp by running brew install webp .

Converting images to WebP

The conversion process is identical on both Linux and macOS. Once you have libwebp installed on your OS, open up the terminal and:

1. cd into path ( where the image you want to convert is located )
2. run cwebp original.jpg -o converted.webp ( replace original and converted with the appropiate names. for the converted pic, you can use whatever name you please )
2.1 you can use the -q option to control the quality level. Generally, a level of 80-85 will give you good results. The command will be: cwebp original.jpg -q 80 -o converted.webp

For the purposes of this article, I’ve used a 6K, 21MB photo. This is the result:

There’s a lot more flags that you can use. To see all the flags and options of libwebp, run cwebp —help

Converting Gif to WebP

By now, you might’ve tried to convert a .gif into .webp, which resulted in an error along the lines of “Error! Could not process file pic.gif”.

To convert a .gif file to .webp, run gif2webp original.gif -o gif.webp .

Converting WebP to PNG

To convert any .webp file into a .png file you can run dwebp original.webp -o image.png

To learn more about WebP, you can check out this page.

Recent Posts

Follow FSM

mastodon FSMdotCOM

We don’t think that using an adblocker = piracy. That’s simply not true.

However, as a small non-corporate website, we would appreciate it if you’d consider whitelisting FSM in your adblock of choice.

Alternatively, consider donating using the options on this page .

LATEST ARTICLES

© 2008-2023 FSMdotCOM. All rights reserved. ✉️ [email protected] Privacy

Источник

Оцените статью
Adblock
detector