Created
September 8, 2022 12:57
-
-
Save mattpocock/872e0a6a65705ee6793b261042fe4e29 to your computer and use it in GitHub Desktop.
This file contains 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
// 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