Linux конвертер webp в jpg

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.

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:

Читайте также:  Linux dhcp server ip address

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.

Источник

Simple way to Convert WebP Images to PNG and JPG/JPEG in Linux

Almost every website now accepts WebP images due to their low size, which reduces image size by 25 to 34% compared to JPGs without much compromising the image quality.

But there are still some sites that will not allow you to upload a WebP image to their platform, and because of that, you need to convert the image to jpg or png.

For the conversion of a WebP image, you can take a screenshot of the image, or else you can use some online tool that is available in the public domain.

However, I don’t do this all because I know the command that can easily convert the WebP image to formats like PNG, JPEG/JPG, and so on.

So let me show you how you can use the dwebp and ffmpeg commands to convert WebP images to PNG, JPG, and JPEG format.

Steps to Convert a WebP Image to PNG, JPG, or JPEG

There are two common commands that you can use in Linux to convert WebP images, which are as follows:

  • dwebp: can be used to convert WebP images into formats like pam, ppm, bmp, tiff, pgm, yuv, and the default, png.
  • ffmpeg: is one of the versatile tools that can be used in several ways to manipulate video and audio, including converting, compressing, and editing multimedia files.

Use dwebp Command to Convert WebP Image

As I said, dwebp is a part of the libwebp library, so when you install libwebp, two interesting tools get installed, like cwebp and dwebp .

cwebp is used to convert a png, jpg, or any other format image into webp, and on the other hand, dwep is used to convert a webp image back to its original format.

Now that you understand which tool we are going to use for converting WebP images, please bring up the system terminal and install it by running the following command:

$ sudo apt install webp // Ubuntu and Debian $ sudo yum install libwebp // AlmaLinux, Fedora $ sudo pacman -S libwebp // Arch Linux

Once the installation is complete, you can now start converting WebP images to PNG format.

The syntax of the dwebp command is simple; you need to first specify the path where the webp image is located, use the -o parameter, and provide the output filename with the .png extension.

$ dwebp input_webp_image.webp -o output.png

Now let me use the above code syntax to convert one of the WebP images to PNG by following the above syntax:

$ dwebp sample_1.webp -o output.png 

Once you get the output, you can check the file information by using the file command, which will confirm the format of the output file.

And with the below screen snip, you can see how I have converted sample_1.webp to output.png.

Convert webp image to png using dwebp command

Sometime you may need to convert more than one WebP image to PNG.

If that is the case, then the above command will not be beneficial, so you can use the for loop to loop through all the webp images in a directory and convert them to png format one by one.

Now go back to the terminal and execute the following command to convert all the WebP images to PNG format.

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

The dwebp command will work fine until you don’t want to convert images into jpg format.

Читайте также:  Настройка линукс сервера ubuntu

Use ffmpeg Command to Convert WebP Image

Alternatively, you can use the ffmpeg command to convert WebP images to PNG, JPG, or JPEG format.

To get started with the conversion, open up your terminal window and execute the following command to check the presence of ffmpeg on your system:

$ ffmpeg -version

If the above command prints the version with configuration information, then you can skip the installation part.

For those who get ffmpeg command not found, run the following command to install ffmpeg:

$ sudo apt install ffmpeg // Ubuntu, Debian $ sudo yum install ffmpeg // AlmaLinux, Fedora $ sudo pacman install ffmpeg // Arch Linux

Once the installation is complete, you can start with the conversion of the WebP image to JPG by running the following command:

$ ffmpeg -i input_webp_image.webp output.jpg

If you want to convert a WebP image to PNG, then change the extension to .png as shown below:

$ ffmpeg -i input_webp_image.webp output.png

But if you want to perform batch operations, then you can use the following command to convert all the WebP files that are available in current directory to png.

$ for FILE in *.webp; do ffmpeg -i "$FILE" -y "$.png"; done

Once you are done, you can verify the type of file using the file command.

Wrap up

That’s all for this short guide where you learn how to convert WebP image to JPG and PNG by using the dwebp and ffmpeg command.

So whenever you just need to convert a WebP image, run any of the following commands:

  • Convert WebP to PNG
    • $ dwebp input_webp_image.webp -o output.png
    • $ ffmpeg -i input_webp_image.webp myfile.jpg

    I hope you are able to convert the image, but if for some reason you are not able to accomplish it, then let us know in the comments section.

    A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.

    Источник

    How to View WebP Images in Ubuntu and Other Linux Distributions

    It’s been over ten years since Google introduced WebP file format for images. WebP provides lossy and lossless compression and WebP compressed files are around 25% smaller in size when compared to JPEG compression, Google claims. Slowly and gradually, WebP is gaining popularity. CDNs automatically convert PNG files to WebP to server images in smaller sizes.

    This is why when you download images from websites, they are downloaded in .wep format.

    The problem is that GNOME Image Viewer, the default image viewer on mayn distributions does not support this format.

    If you try to open a webp image, it opens the WebP image in a web browser. If you try top open with photo viewer, it throws an error:

    Could not load image XYZ.webp
    Unrecognized image file format

    webp error linux

    There are ways to get rid of this annoyance. In this tutorial, you’ll see:

    • How to add WebP support to GNOME’s Image Viewer (recommended)
    • How to use other tools for opening WebP files
    • How to convert WebP images to PNG or JPEG

    Let’s go through them one by one.

    Method 1: Add WebP support to GNOME Image Viewer in Ubuntu and Other Linux (Recommended)

    By default, the photo viewer does not support WebP images files. However, you can add WebP support by installing webp-pixbuf-loader library. Not only it allows you to open WebP files in GNOME Image Viewer, it also displays thumbnails for WebP files in the file explorer.

    On Ubuntu-based Linux distributions, you can install this library using a PPA. Use the following commands one by one:

    sudo add-apt-repository ppa:helkaluin/webp-pixbuf-loader sudo apt update sudo apt install webp-pixbuf-loader

    In other distributions like Fedora and SUSE, you should be able to use the package manager and install it from the distribution’s repositories.

    sudo dnf install webp-pixbuf-loader
    sudo pacman -S webp-pixbuf-loader

    Once it is installed, you don’t have to do anything else. No need to restart or log out. You’ll see that the WebP images are now displayed with thumbnails:

    webp images without thumbnail

    You should also change the default application in Ubuntu to open it with Image viewer with double click:

    open webp image viewer

    This is what I recommend but if for some reasons, you cannot install this additional library, you can use another application.

    Method2: Use gThumb to view WebP images in Ubuntu and other Linux

    One of the alternative photo viewer application is gThumb and it supports WebP images by default.

    To install gThumb in Ubuntu and other Ubuntu based Linux distributions, use the command below:

    sudo apt-get install gthumb

    Once installed, you can simply rightly click on the WebP image and select gThumb to open it. You should be able to see it now:

    WebP Image in gThumb in Ubuntu 16.04

    Make gThumb the default application for WebP images in Ubuntu

    For Ubuntu beginners, if you like to make gThumb the default application for opening WebP files, just follow the steps below:

    Step 1: Right click on the WebP image and select Properties.

    Open WebP images in Ubuntu Linux

    Step 2: Go to Open With tab, select gThumb and click on Set as default.

    Set gThumb the default application for WebP images in Ubuntu Linux

    Method 3: Convert WebP images to PNG and JPEG in Linux

    Since you are dealing with WebP images, you may want to learn about converting WebP to regular images.

    There are two ways to convert WebP images in Linux:

    1. Using command line to convert WebP images in Linux

    You need to install WebP tools first. Open a terminal and use the following command:

    Convert JPEG/PNG to WebP

    We’ll use cwebp command (does it mean compress to WebP?) to convert JPEG or PNG files to WebP. The command format is like:

    cwebp -q [image_quality] [JPEG/PNG_filename] -o [WebP_filename]

    For example, you can use the following command:

    cwebp -q 90 example.jpeg -o example.webp

    Convert WebP to JPEG/PNG

    To convert WebP images to JPEG or PNG, we’ll use dwebp command. The command format is:

    dwebp [WebP_filename] -o [PNG_filename]

    An example of this command could be:

    dwebp example.webp -o example.png

    2. Using GUI tool to convert WebP to JPEG/PNG

    For this purpose, we will use XnConvert which is a free but not open source application. You can download the installer files from their website:

    Note that XnConvert is a powerful tool that you can use for batch resizing images. However, in this tutorial, we shall only see how to convert a single WebP image to PNG/JPEG.

    Open XnConvert and select the input file:

    Convert WebP image to PNG in Ubuntu Linux

    In the Output tab, select the output format you want it to be converted. Once you have selected the output format, click on Convert.

    Converting WebP images to JPEG in Ubuntu Linux

    That’s all you need to do to convert WebP images to PNG, JPEg or any other image format of your choice.

    What’s your pick?

    I hope this detailed tutorial helped you to get WebP support on Linux and helped you to convert WebP images. How do you handle WebP images in Linux? Which tool do you use? From the above described methods, which one did you like the most?

    Источник

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