4

I have a bunch of webp images and need to convert them to png format. I know png supports different color modes like grayscale which I need.

Is there any Linux tool or online services to achieve this fast and easy?

I tried different online converters, but all of them convert webp to png with default RGB color mode.

2

5 Answers 5

7

This can be done on the command line using the imagemagick package. This has the advantage that it becomes easy to script for an entire directory of images (hint: either combine with the find -exec command or a bash for loop).

First install the package:

sudo apt update && sudo apt install imagemagick

Download an example webp image to test it out on:

wget https://www.gstatic.com/webp/gallery/1.webp

The imagemagick command:

convert 1.webp -colorspace Gray 1.png

You should now have a black and white png image in the same directory. -colorspace Gray converts the image to black and white.

For more info, try: man convert

3

Use GIMP 2.10.

click file>open and select open .webp file. Now go to image>mode>Grayscale Now go to File>export as and export as yourfilename.webp

and that is your image is converted to grayscale. While exporting it is upto you if want to select lossless or lossy.

2
  • Wait... there's lossy PNGs? Nov 1, 2021 at 17:25
  • No I write about .webp format.
    – Ajay
    Nov 1, 2021 at 17:59
3

Use Inkscape 1.1.1,

Open .webp file by click Open in File menu [File > Open]
Now click on Export PNG Image... in File menu. [File > Export PNG Image...]
On the side, in the Export PNG Image tab and Drawing sub-tab, click on the Advanced accordion.
Set Bit depth on Gray_1, Gray_2, Gray_4, Gray_8, Gray_16, GrayAlpha_8 or GrayAlpha_16 based on your needs.
Enter Filename with .png extension and click on Export button.

This will convert your webp file to grayscale png.

2
  • 1
    Is there a benefit to using Inkscape (optimised for vector graphics) over GIMP for raster file converting between these raster formats?
    – Chris H
    Oct 31, 2021 at 18:04
  • @ChrisH Two separate applications offer different settings to the user. However, this is a way to convert webp to png. Oct 31, 2021 at 20:25
2

ffmpeg example

Using the format filter to set grayscale:

ffmpeg -i input.webp -vf format=gray output.png

See FFmpeg & Black and White Conversion for several other methods.

Convert an entire directory

Use a Bash for loop:

for f in *.webp; do ffmpeg -i "$f" -vf format=gray "${f%.*}.png"; done

Adapted from How do you convert an entire directory with ffmpeg?

1

If you are looking for an online tool with the support of converting to grayscale PNG, this online WebP to PNG converter by Vertopal will do the trick.

Based on the tools section bottom of the page, it supports 8-bit grayscale:

Convert WEBP to Black & White (monochrome) PNG, 8-bit Grayscale PNG, 24-bit RGB PNG, and 32-bit RGBA PNG.

I used a WebP image from Google Developers WebP Gallery for the test:

Original WebP Image

Converted to 8-bit grayscale PNG

It worked just fine. Good luck.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .