Converting .webp images

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Converting .webp images

Post by rossdv8 »

I'm not sure where to post this, but because it is something that annoys a few of my friends, I'll post it in the Mint Chat.

Google's insistence on using .webp for web page images is a pain. I know we shouldn't be downloading images from web pages - but a lot of us do. And if we use right click in Chrome/Chromium we end up with a heap of .webp images that need specific viewers, and often don;t show as thumbnails in file managers.

I was converting one file at a time using the dweb command from webp tools, but I wanted to do a batch convert. I found that Flemming Mahler had shared a simple command to batch convert, so I'll share it here for anyone else who finds .webp to be annoying.
The following is copied from one of my blogs:
******
Flemming Mahler posted this little solution to converting .webp files (google's current image format - not liked by many image viewers) to png (easily read by common image viewers) on the Netfactory website

https://netfactory.dk/2015/07/16/bulk-c ... ng-format/

(1) Install webp tools:
sudo apt install webp

(2) Run the following command in the terminal:
find . -name "*.webp" | xargs -I {} dwebp {} -o {}.png

Wait a few moments...
Cheers,
RossD
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Converting .webp images

Post by smurphos »

Just download them in the original uncompressed format.

https://www.howtogeek.com/325864/how-to ... eg-or-png/
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
karlchen
Level 23
Level 23
Posts: 18155
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Converting .webp images

Post by karlchen »

Hi, smurphos.

Seems a bit as if the "how to geek" advice depends a bit too much on some Google internal naming convention.
Try the given advice on the webp image linked to below e.g. :wink:
https://res.cloudinary.com/hp20rcdax/im ... hexiwblxik

--
Added 13:00 CET: Beware, the above 2 lines reveal a PEBCAK issue, cf. post below.

Cheers,
Karl
Last edited by karlchen on Sat Dec 15, 2018 8:06 am, edited 1 time in total.
Reason: Added note about my PEBCAK mistake
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 750 days now.
Lifeline
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Converting .webp images

Post by smurphos »

That link downloads as jpeg straight from the context menu for me karlchen...

Edit to add - as jpeg on Android Chrome - not on regular Chrome. How interesting,,,,
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
karlchen
Level 23
Level 23
Posts: 18155
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Converting .webp images

Post by karlchen »

Hi, smurphos.

You are right. I failed to notice. :oops:
Actually the image is the current Pale Moon startpage background image.
On the Pale Moon startpage, I right-clicked and instructed Pale Moon to "display the background image".
Next I checked "Image Info". Of course, it truethfully told me it were a .webp image.
In this "Image Info" box, there is a "Save as" button as well. Of course, clicking this button will save the .webp file to disk.
I simply should have closed the "Image Info" dialogue, right-clicked on the image again and selected "Save image as".
Doing so saves as .jpeg.

PEBCAK.
Mystery solved.
Thanks,
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 750 days now.
Lifeline
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: Converting .webp images

Post by rossdv8 »

I simply should have closed the "Image Info" dialogue, right-clicked on the image again and selected "Save image as".
Doing so saves as .jpeg.
When using Chrome or Chromium browsers, right clicking on an image and choosing 'Save image as..' (in my MInt 19) only gives two 'Filter' options for file type:

image/webp
Application/octet-stream

In many web pages these days, a story will often contain a mix of .webp and .jpeg images. The method posted just allows people like me who have a preferred image viewer that does not show .webp images to quickly and easily get a compatible set of images from webp stuff.
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Converting .webp images

Post by smurphos »

Cheers rossdv8. It's handy to have a conversion method, but as any conversion will probably be lossy if there was a method to reliably fool Chrome/the Website to offer the non webp version of the image in the first place that would be handy to know as-well. I'm intrigued....

I found a few more options here to get Chrome to download webp as png in the first place - https://www.hongkiat.com/blog/save-webp ... pg-or-png/
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
MrGrimm

Re: Converting .webp images

Post by MrGrimm »

rossdv8 wrote: Fri Dec 14, 2018 9:34 pm Google's insistence on using .webp for web page images is a pain. I know we shouldn't be downloading images from web pages - but a lot of us do.
it's MOST of us do. and most of us do feel it's our right. i personally google a fix to something or google how to do something once i know the info on the page i selected works i select everything to do with the tutorial and save it, so i don't have to go searching again, always have a local copy.
Last edited by MrGrimm on Sun Dec 16, 2018 12:17 pm, edited 1 time in total.
phd21
Level 20
Level 20
Posts: 10103
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: Converting .webp images

Post by phd21 »

HI rossdv8, MrGrimm, etc...

It is simple to convert almost any image format to another image format using various tools. "XnConvert" and "XnViewMP" can both easily convert image formats like ".webp" to other images formats (.jpg, .png, etc...) one at a time or many at a time (batch) and works on Linux or MS Windows or Mac systems. "Converseen" is a great image converter but I don't know if it does ".webp". Most image editors can also convert an image from one format to another format.

XnConvert · One of the Best Batch Image Processing
- scroll down select Linux deb file then save it and double-click to install it.
https://www.xnview.com/en/xnconvert/

Searching the "Synaptic Package Manager (SPM)" for "webp" and installing related packages is also a good thing to do.

Hope this helps ...
.
xnconvert1.jpg
.
xnconvert2_copy.jpg
Last edited by phd21 on Sun Dec 16, 2018 12:33 pm, edited 1 time in total.
Phd21: Mint 20 Cinnamon & xKDE (Mint Xfce + Kubuntu KDE) & KDE Neon 64-bit (new based on Ubuntu 20.04) Awesome OS's, Dell Inspiron I5 7000 (7573) 2 in 1 touch screen, Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram, Intel 4 Graphics.
MrGrimm

Re: Converting .webp images

Post by MrGrimm »

very nice, thanks
phd21
Level 20
Level 20
Posts: 10103
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: Converting .webp images

Post by phd21 »

Hi MrGrimm,

You are welcome...
Phd21: Mint 20 Cinnamon & xKDE (Mint Xfce + Kubuntu KDE) & KDE Neon 64-bit (new based on Ubuntu 20.04) Awesome OS's, Dell Inspiron I5 7000 (7573) 2 in 1 touch screen, Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram, Intel 4 Graphics.
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: Converting .webp images

Post by rossdv8 »

One of the fun things about this forum is the amount of extra information that comes to light. For example I didn't know about the "delete the last 3 characters" in a 'Copy image address' tab. That is handy.
I should add that unless I want a Highish Res image, I often don't even bother messing around. If I see a diagram or something I want I simply use Spectacle to copy a rectangular region.

But more often than not I just right click > save image as, and don;t even look at the file extension. That is when I discover later that I have half a dozen .webp images. And the reason I shared the method.

Anyway, some of the replies have shown me neat tricks to avoid ending up with those images - as long as I remember to do them :-)

Cheers,
RossD
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
Raycoupe
Level 4
Level 4
Posts: 267
Joined: Thu Dec 13, 2018 10:24 am

Re: Converting .webp images

Post by Raycoupe »

rossdv8 wrote: Fri Dec 14, 2018 9:34 pm (1) Install webp tools:
sudo apt install webp

(2) Run the following command in the terminal:
find . -name "*.webp" | xargs -I {} dwebp {} -o {}.png

Wait a few moments...
Cheers,
RossD
Thanks, that little tip was just what I needed.
Hardware, operating systems, software and networking are are nothing else than necessary, cumbersome and easily replaceable evils to store and provide data. Triple backup your data at least, twice on-site, and another copy off-site.
User avatar
axrusar
Level 6
Level 6
Posts: 1423
Joined: Sat Jan 30, 2021 5:30 pm

Re: Converting .webp images

Post by axrusar »

I would simply use Flameshot to take a screenshot of the desired image and save in jpg or PNG.
Just a different option
Linux Mint Una Cinnamon 20.3 Kernel: 5.15.x | Quad Core I7 4.2Ghz | 24GB Ram | 1TB NVMe | Intel Graphics
Image
User avatar
rossdv8
Level 7
Level 7
Posts: 1737
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: Converting .webp images

Post by rossdv8 »

I would simply use Flameshot to take a screenshot of the desired image and save in jpg or PNG.
Just a different option
The Original Post was about converting images already downloaded as .webp

There are lots and lots of ways to avoid that particular trap - but there are lots of people who already have .webp images who didn;t think of reading the 'How To avoid downloading .webp' post and already have the things scattered through their various image or download folders..

I should add that it is becoming less and issue because more and more Linux graphics programs/viewers are ok with them.
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
duracell80
Level 3
Level 3
Posts: 111
Joined: Fri Sep 23, 2022 5:51 pm

Re: Converting .webp images

Post by duracell80 »

Requires:
- dwebp
- zenity

Optional:
- Can convert using ffmpeg

Here's what I'm doing in nemo actions for this. It would be handy to know how to do a batch with this by selecting multiple files in nemo. I haven't got that advanced yet would it still work with %F and how to get multiple into the script? Is it the "Selection=S" line in the .nemo_action?

Code: Select all

$ sudo apt install zenity webp
Webp to JPG (~/.local/share/nemo/actions/ext-convert-webp_jpg.nemo_action)

Code: Select all

[Nemo Action]
Name=Convert to JPG
Comment=Converts a webp file to jpeg
EscapeSpaces=true
Exec=/home/yourusername/.local/share/nemo-scripts/ext-convert_webp.sh "jpg" %F
Selection=S
Extensions=webp
Dependencies=dwebp;zenity

Webp to PNG (~/.local/share/nemo/actions/ext-convert-webp_png.nemo_action)

Code: Select all

[Nemo Action]
Name=Convert to PNG
Comment=Converts a webp file to png
EscapeSpaces=true
Exec=/home/yourusername/.local/share/nemo-scripts/ext-convert_webp.sh "png" %F
Selection=S
Extensions=webp
Dependencies=dwebp;zenity
~/.local/share/nemo-scripts/ext-convert_webp.sh

Code: Select all

#!/bin/sh

FILE_DIR=$(dirname "$2")
FILE_BIT=$(basename "$2")

FILE_NME=${FILE_BIT%%.*}
FILE_EXT=${FILE_BIT##*.}


(
echo "50"
echo "# Converting WebP Image to ${FILE_NME}.${1}"

if [ "$1" = "jpg" ]; then
    #ffmpeg -i "$2" -y "${FILE_DIR}/${FILE_NME}.jpg"
    dwebp "$2" -o "${FILE_DIR}/${FILE_NME}.jpg"
elif [ "$1" = "png" ]; then
    #ffmpeg -i "$2" -y "${FILE_DIR}/${FILE_NME}.png"
    dwebp "$2" -o "${FILE_DIR}/${FILE_NME}.png"
elif [ "$1" = "bmp" ]; then
    dwebp -bmp "$2" -o "${FILE_DIR}/${FILE_NME}.bmp"
fi

echo "75" ; sleep 1
echo "# Completed ${FILE_NME}.$1"
echo "100" ; sleep 1
) |
zenity --progress \
  --title="Converting to ${1}" \
  --text="Running ffmpeg ..." \
  --percentage=25 \
  --width=500 \
  --timeout=1

if [ "$?" = -1 ] ; then
        zenity --error \
          --text="Conversion canceled"
fi
Post Reply

Return to “Tutorials”