MicrosoftPowershellTips & TricksWindows 10

How to Convert WebP to JPG in Bulk Using PowerShell


WebP is a modern image format developed by Google that offers superior compression compared to traditional JPGs and PNGs. This results in smaller files, helping websites load faster. However, not all image editing software and devices fully support WebP yet. If you need to use your images with older tools or platforms, converting them to the universally-supported JPG format might be necessary. Here’s how to automate this process with PowerShell.


PowerShell Script

# Specify the folder containing your WebP files
$webpFolder = "C:\Your\WebP\Folder\Path"

# Path to the cwebp.exe file (modify if needed)
$cwebpPath = "C:\Path\To\Your\cwebp.exe"

# Get all WebP files in the folder
$webps = Get-ChildItem -Path $webpFolder -Filter "*.webp"

foreach ($webp in $webps) {
    # Create output JPG filename
    $jpgFileName = $webp.BaseName + ".jpg"
    $jpgFilePath = Join-Path $webpFolder $jpgFileName

    # Construct the command to run cwebp
    $command = "& '{0}' '{1}' -o '{2}'" -f $cwebpPath, $webp.FullName, $jpgFilePath

    # Execute the conversion command
    Invoke-Expression $command


  1. Setting Folders: Replace placeholders with the path to your WebP folder and the location of your cwebp.exe file.

  2. Retrieving WebP Files: The code finds all .webp files in the specified folder.

  3. Generating JPG Names: The script creates an output JPG filename with the same base name as the input WebP file.

  4. Constructing the cwebp Command: The script builds the command to execute the cwebp.exe utility to perform the conversion.

  5. Executing the Command: The Invoke-Expression command runs the cwebp command, converting each WebP to JPG.

Recommended For You:  How To Install Veeam Backup & Replication 10

How to Run the Script

  1. Download cwebp.exe: Get it from Google Developers and place it in a convenient location.
  2. Open PowerShell: Find it in your Windows Start menu.
  3. Paste the Code: Paste the code into the PowerShell window.
  4. Modify Paths: Ensure the paths to your WebP folder and cwebp.exe are correct.
  5. Execute: Press Enter to run the script.

Additional Tips

  • Transparency: If you need to convert WebP images to JPG while preserving transparency, consider using PNG format instead. PNG offers both transparency and a wide color range.

More Image Conversions with PowerShell

Interested in automating other image conversion tasks? Check out these related guides:

Let me know if you have other image formats you’d like assistance converting with PowerShell!

Muhammad Faizan

Hi, My name is Muhammad Faizan and i have spent last 15 years working as System Administrator mainly with Microsoft Technologies. I am MCSE, MCTP, MCITP, certified professional. I love scripting and Powershell is the scripting language i am in love with.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Back to top button