Skip to content

Instantly share code, notes, and snippets.

@amorev

amorev/convert.php

Created Sep 4, 2020
Embed
What would you like to do?
<?php
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$fileInfo = explode('.', $entry);
$fileName = $fileInfo[0];
$fileExt = $fileInfo[1];
if ($fileExt === 'png') {
continue;
}
echo $entry;
exec('dwebp '.$entry.' -o '.$fileName.'.png', $a, $b);
if ($b != 0) {
echo 'not webp';
} else {
exec('convert '.$fileName.'.png '.$entry, $a, $b);
if ($b == 0) {
echo 'success';
}
}
echo PHP_EOL;
}
}
closedir($handle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.