- Download webp decoder from Google's WebP utilities and libraries
- Place dwebp.exe on the same folder with the images
- Create PHP file and paste the source below
- Run
Created
July 31, 2022 02:30
-
-
Save catwhocode/22eecdf3ab582826e334b374abc2bc35 to your computer and use it in GitHub Desktop.
PHP: Batch convert webp to png
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = './'; | |
$files = scandir($path); | |
$files = array_diff(scandir($path), ['.', '..','dwebp.exe', 'convert.php']); | |
foreach($files as $file){ | |
$result = shell_exec('.\dwebp.exe "' . $file . '" -o "' . str_replace('.webp', '', $file) . '.png"'); | |
echo $result . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment