Easy way to batch convert webp images on your PC using bat

Easy way to batch convert webp images on your PC using bat

Today I saved an AI generated image to my PC.  I then wanted to open it using my goto paint program, however as its a bit old it doesnt support webp format.

What is webp format?

Webp is a modern image format designed to improve the web experience. Compared to popular formats like JPEG, WebP shines in two key areas: file size and features. With up to 30% smaller file sizes, WebP speeds up page loading times, enhancing user experience and SEO. But it’s not just about shrinking bytes. WebP supports features like lossless compression, transparency, and animation, opening doors for richer visual storytelling on the web. While adoption is growing, some older browsers lack native .WebP support, requiring additional considerations during website development. Overall, WebP represents a significant step forward in image optimization, balancing visual quality, file size, and feature versatility.

So I know there are lots of online and offline tools for image conversion but you got install or sign up and get to grips with their UI and then hope its not a trial version or has free usage limits, so I decided to try another way.

So I decided to use Image Magic and a .bat file to do the job. What this bat file will do is fast batch convert all webp images in a folder to png. However you can modify the code to convert to other formats such as jpeg.

What is Image Magick

This open-source software suite empowers developers, designers, and anyone interested in image processing with a vast array of tools. Resize, crop, convert, apply filters, adjust colors, and more, all through a command-line interface or scripting. Its versatility and powerful image processing capabilities make ImageMagick a popular choice for automating tasks, batch conversions, and creative image editing.

Convert .webp to .png using image magick and bat

Ok so the first thing to be aware of is that this will work on Windows or Mac, but you first need to download and install Image Magick from here.  Make sure you download the right version.  My example below will be for the Windows version however you should be able to do the same on Mac.

Once installed Image Magick you can open the command prompt and type “magick -version” to see if it installed and accessible from command prompt.

Next open a new text file on your PC.  Copy the code below into it and then save the file as a .bat file (not .txt)

@echo off

set /p folder_path=Enter the folder path containing .webp images: 

if not exist "%folder_path%" (
  echo Folder path does not exist. Please check and try again.
  pause
  exit /b
)

cd /d "%folder_path%"

for %%f in (*.webp) do (
  magick "%%f" "%%~nf.png"
)

echo .webp images converted to .png successfully!
pause

Now you can just double click the .bat file to execute the code. You will be asked for a path to a local folder. It will check to see if the folder exists and if it does it will convert ALL .webp images in the folder to .png format

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.