Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Created July 31, 2022 02:30
Show Gist options
  • Save catwhocode/22eecdf3ab582826e334b374abc2bc35 to your computer and use it in GitHub Desktop.
Save catwhocode/22eecdf3ab582826e334b374abc2bc35 to your computer and use it in GitHub Desktop.
PHP: Batch convert webp to png
<?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