110

I'm using ubuntu 12.04. I've installed libwebp2 & libwebp-dev

So far, no example found on the net of converting webp to jpg.

Some webp files can easily converted by using imagemagick with command

convert file.webp file.jpg

but lots of webp files cannot be converted and give error:

convert: no decode delegate for this image format `file.webp' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `file.jpg' @ error/convert.c/ConvertImageCommand/3011.

--------added

This is the file: http://www.filedropper.com/file_144

9
  • Could you post some of the files that cannot be converted so we can have a go?
    – terdon
    Commented Mar 30, 2013 at 17:39
  • Any errors when ImageMagick fails to convert?
    – dartonw
    Commented Mar 30, 2013 at 17:44
  • @dartonw Error has been updated
    – apasajja
    Commented Mar 30, 2013 at 17:51
  • 2
    Does convert -list format contain WebP?
    – peterph
    Commented Mar 30, 2013 at 22:24
  • 1
    convert -list format dont have WebP
    – apasajja
    Commented Mar 31, 2013 at 4:50

10 Answers 10

147

Google already provided the tool to decode webp images in the libwebp package, your uploaded file works on Arch.

dwebp file.webp -o abc.png

For the encoding tool, check the cwebp command.

In Ubuntu you can install the tools with:

sudo apt install webp

On RHEL/CentOS:

 yum install libwebp libwebp-tools

And you might consider using this online tool.

11
  • 10
    Unfortunately dwebp only converts webp to png, but not to jpg.
    – rumpel
    Commented Oct 29, 2013 at 8:30
  • 2
    @rumpel thx, it failed to open the .jpg, but when I put .png it worked! Commented Dec 8, 2014 at 3:49
  • 3
    In 14.04 I needed to install the package webp it was not available until I installed that. I was confused because I had install all the libwebp and libweb-dev packages. Commented May 5, 2015 at 17:29
  • 4
    Use dwebp for webp->png, and then convert for png->jpg. Using pipe. dwebp 1.webp -o - | convert - 1.jpg
    – steve
    Commented Jul 15, 2016 at 17:57
  • 2
    For windows use the following command for %f in (*.webp) do dwebp.exe "%f" -o "%~nf.png" Commented Nov 18, 2016 at 18:21
54

ffmpeg can do this. Useful if you already have ffmpeg. No need for installing other tools.

Simply:

ffmpeg -i file.webp out.png
3
  • 1
    It works, but the png is 11x larger.
    – RonJohn
    Commented Jul 26, 2019 at 14:30
  • 2
    it works. It is good for jpg image, but png format is very large.
    – mahfuz
    Commented Nov 10, 2019 at 8:46
  • 1
    This worked for me, using dwebp produced broken jpegs on the images I did.
    – Jonno_FTW
    Commented Nov 27, 2019 at 0:58
28

Convert all webp files within a directory

find ./ -name "*.webp" -exec dwebp {} -o {}.png \;

Note: dwebp is in the libwebp package

4
  • 6
    For Ubuntu 16.04 I needed to install it with sudo apt-get install webp.
    – PhoneixS
    Commented Aug 18, 2017 at 17:58
  • Dont know if ment as a feature or a bug, but all the files will be saved as file.webpg.png instead of simply file.png
    – mrfr
    Commented Jul 9, 2019 at 20:35
  • It's a feature for simplicity... I have a image hashing algorithm which automatically renames images, so I intended to rename the files using that. Commented Jul 11, 2019 at 1:00
  • Using ffmpeg: find ./ -name "*.webp" -exec ffmpeg -i {} {}.jpeg \; Commented Feb 13, 2021 at 19:39
11

From the directory containing the webp files:

for x in *.webp; do ffmpeg -i "$x" "${x%.webp}.jpg"; done
2
  • 1
    Add -loglevel quiet as ffmpeg option to suppress the copious log output.
    – Sri
    Commented Apr 28, 2021 at 5:35
  • This brought the image quality significantly down. Commented Aug 16, 2021 at 11:28
3

Use dwebp for webp->png, and then convert for png->jpg. Using pipe.

dwebp 1.webp -o - | convert - 1.jpg
1

There is another online tool available here which can help you on this:

but if you want a local tool, you can use this one:

and use it like this:

1) chmod a+x webpconv

2) ./webpconv -format PNG <YOUR_WEBP_FILE>.webp

The overall structure is like this:

webpconv [-output_dir dir] [-format format] [-quality quality] input_file(s)

Example) To convert a .png image to WebP with a quality of 90 you would enter:

webpconv -quality 90 /home/user/image_name.png

and to convert a WebP file to a PNG one:

webpconv -format PNG /home/user/image_name.webp

0

To convert multiple jpg to webp, using cwebp:

find ./ -name "*.jpg" -exec cwebp -q 70 {} -o {}.webp \

Thunar Custom Action:

for file in %F; do cwebp "$file" -o "${file%%.*}".webp; done

Thunar Custom Action, moving webp images to subfolder:

mkdir %d/webp && cd %d; for file in %N; do cwebp "$file" -o "webp/${file%%.*}".webp; done

Cwebp's default quality setting is 75.

0

install the webp package with sudo apt install webp, after that it should work.

1
  • why the downvote? this exact solution got incorporated into the accepted answer after I gave mine Commented Oct 28, 2020 at 11:29
0

for x in ls *.webp; do ffmpeg -i $x ${x%.webp}.jpg; done which is solution stolen from Byram Sewell and Jeff Bowman https://stackoverflow.com/a/17844019/146745

-1

I found this method faster for my 1 time need.

  1. Take screenshot with webp image open in chrome.
  2. Paste into paint program.
  3. Crop and save.
3
  • 8
    The questioner was looking for a command line solution...
    – jasonwryan
    Commented Jun 10, 2014 at 4:06
  • 1
    I think it could be made as a command line by using Shutter and taking a screenshot of a window without window decorations, all in a script; could be fun to code :) Commented Aug 11, 2014 at 22:30
  • Screenshots loose much of the original quality, therefore, they voted "-1" to your answer. It is not a good solution. Commented Jan 3, 2022 at 8:17

You must log in to answer this question.

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