scionoftech / webp-converter

[DEPRECATED] A small node.js library for converting any image to webp file format or converting webp image to any image file format.
MIT License
229 stars 43 forks source link

Error: spawn lib/libwebp_win64/bin/webpmux.exe ENOENT #17

Closed Tenpi closed 2 years ago

Tenpi commented 4 years ago

I get the following error when trying to convert a bunch of files to webp:

101 { Error: spawn lib/libwebp_win64/bin/webpmux.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Full code:

public encodeWebp = async (files: string[], delays: number[], dest?: string) => {
        const pathIndex = files[0].search(/\d{8,}/)
        const pathDir = files[0].slice(0, pathIndex)
        const subDir = files[0].match(/(?<=\/)(\d{8,})(?=\/)/)[0]
        if (!dest) dest = `${pathDir}${subDir}.webp`
        const webpArray: string[] = []
        const inputArray: string[] = []

        async function convertToWebp(ifile: string, wFile: string) {
            return new Promise((resolve) => {
                webp.cwebp(ifile, wFile, "-q 80", (status, error) => {
                    resolve()
                })
            })
        }

        for (let i = 0; i < files.length; i++) {
            const webpFile = `${files[i].slice(0, -4)}.webp`
            webpArray.push(webpFile)
            await convertToWebp(files[i], webpFile)
        }

        for (let j = 0; j < webpArray.length; j++) {
            inputArray.push(`${webpArray[j]} +${delays[j]}`)
        }
        webp.webpmux_animate(inputArray, dest, "10", "255,255,255,255", (status, error) => {console.log(status, error)})
    }

Obviously it says that the file is missing, but I did check the directory and webpmux.exe is there...