Skip to content

Instantly share code, notes, and snippets.

@mattpocock
Created September 8, 2022 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpocock/872e0a6a65705ee6793b261042fe4e29 to your computer and use it in GitHub Desktop.
Save mattpocock/872e0a6a65705ee6793b261042fe4e29 to your computer and use it in GitHub Desktop.
// Name: convert to webp
import "@johnlindquist/kit";
import * as path from "path";
const folder = await selectFolder("Select folder to convert from png to webp");
const files = await readdir(folder);
const pngFiles = files
.filter((file) => file.endsWith(".png"))
.map((file) => ({
input: path.join(folder, file),
output: path.join(folder, file.replace(".png", ".webp")),
}));
// inspect(pngFiles);
for (const file of pngFiles) {
// await exec(`cwebp ${file.input} -o ${file.output}`);
await $`source ~/.bash_profile && ffmpeg -i "${file.input}" -c:v libwebp "${file.output}"`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment