Logo

dev-resources.site

for different kinds of informations.

Automate WEBP To PNG With A Simple .Bat File

Published at
4/29/2024
Categories
bat
batch
image
tip
Author
spenceryonce
Categories
4 categories in total
bat
open
batch
open
image
open
tip
open
Author
12 person written this
spenceryonce
open
Automate WEBP To PNG With A Simple .Bat File

Automate Your Image Conversion with a Simple Batch Script

Managing different file formats efficiently is crucial in various development projects, from web development to organizing personal media. To streamline this task, I've developed a handy batch script that automates the conversion of WEBP images to PNG or PPM formats. This script was inspired by a discussion I came across on a GitHub Gist thread, highlighting the need for a reusable, effective solution.

Inspiration Behind This Tool

The idea for this script originated from a GitHub Gist conversation where developers shared their struggles with converting WEBP files using dwebp.exe. Most solutions were temporary fixes rather than sustainable ones. Reminded of the user-friendly philosophy behind my previous project, VSGraph, I set out to craft a tool that would handle batch conversions and clean up afterward efficiently.

What the Script Does

Using dwebp.exe from Google's WebP toolkit, this script efficiently converts WEBP images into PNG or PPM formats and offers an option to automatically delete the original files after conversion. It is designed to:

  1. Detect and Convert Images Automatically: It locates all .webp files in the execution directory and converts them to the specified format.
  2. Manage Clean-Up Effectively: After conversion, it can remove the original .webp files to save space and keep the directory tidy.

How to Use the Script

Setup

  1. Download dwebp.exe: Download this executable from Google at WebP Download.
  2. Prepare Your Script Environment: Place dwebp.exe in the same directory as your WEBP files or a globally accessible directory included in your system's PATH.

Using the Script

  1. Create the Script: Write your own script using the guidelines below or download the full script from my GitHub Gist.
  2. Run the Script: Navigate to your image directory in the command prompt and type convert_webp.bat for PNG output or convert_webp.bat -ppm for PPM output.
@echo off
setlocal

REM Convert all WEBP files to PNG or PPM and then delete the WEBP files
for %%f in (*.webp) do (
    echo Converting %%f...
    dwebp.exe "%%f" -o "%%~nf.png"
    if errorlevel 1 (
        echo Failed to convert %%f
    ) else (
        del "%%f"
        echo Deleted %%f
    )
)

echo Conversion complete.
pause
Enter fullscreen mode Exit fullscreen mode

Get the Full Script

If you prefer not to build the script yourself or want to see the full implementation, you can find it on my GitHub Gist. Simply visit this link to view or download the complete script: Convert WEBP to PNG/PPM Batch Script.

How It Works

Like connecting nodes in VSGraph, this script uses simple loops and conditions to manage file conversions. It's designed to be accessible and easy to use, just like a visual shader graph editor.

Whatโ€™s Next?

You tell me! This is fully open-source code and would love to see what the community does with it.

If you have suggestions for improvements or additional features, or if you've found creative ways to use this tool, please share your thoughts in the comments below!

tip Article's
30 articles in total
Favicon
Ctrl+Alt+Arrow (Right, Left) not working on IntelliJ
Favicon
if locals == globals
Favicon
Version Control Best Practices with Git and GitHub
Favicon
Creating generic types for API (backend) responses
Favicon
Null or Nothing? Unmasking the Mystery of Parameters in Dart
Favicon
List of prompts for successful affiliate marketing
Favicon
My impressions about the book The Clean Coder ๐Ÿงน๐Ÿ“š
Favicon
Why You Should Use GraphQL Playground โฐ
Favicon
Automate WEBP To PNG With A Simple .Bat File
Favicon
In CMS Made Simple, how do you change the theme?
Favicon
A importancia de fazer testes
Favicon
Conditional Styles with CSS :has
Favicon
Do you know that 0.1 + 0.2 is not equal to 0.3?
Favicon
How to save datetime data that is relevant to multiple countries or timeย zones?
Favicon
What I've Learned About Git from Senior Colleagues (Part 1 - git stash)
Favicon
A (somewhat) deep dive into TypeScript constructor intricacies, step-by-step
Favicon
Faster Color picking in Tailwind
Favicon
Evita usar UpperCase o LowerCase C#
Favicon
#DeveloperTipOfTheWeek - Application Security
Favicon
Running out of space on a developer's machine
Favicon
Alert vs confirm in javascript
Favicon
Quick Tip: Counting up to a limit
Favicon
Quick Tip: findFile
Favicon
Time Saving Tip #2 - User Snippets in VSCode
Favicon
Notify Yourself After Completing a Long-Running Bash Process
Favicon
Time Saving Tip #1 - Use Voice Dictation
Favicon
๐Ÿš€ Unveiling the Power of OpenSearch in 202$: A Comprehensive Overview๐Ÿ˜Ž
Favicon
Quick Tip: Checking if a Number is in Range
Favicon
Building a TypeScript Simple Channel (Like Golang)
Favicon
Ubuntu Minimal Install

Featured ones: