@nwrks/webp-converter
Version:
A small node.js library for converting any image to webp file format or converting webp image to any image file format.
34 lines (31 loc) • 1.37 kB
JavaScript
const resolve = require("resolve/sync");
const path = require("path");
//get os type then return path of respective platform library
const webpmux = function () {
const modulePath = resolve("@nwrks/webp-converter", { basedir: __dirname });
if (!modulePath) throw new Error("webp-converter not found");
if (process.platform === "darwin") {
if (process.arch === "arm64") {
return path.join(modulePath, "../../", "/bin/libwebp_osx_arm/bin/webpmux"); //return osx library path
}
return path.join(modulePath, "../../", "/bin/libwebp_osx/bin/webpmux"); //return osx library path
} else if (process.platform === "linux") {
if (process.arch === "arm64") {
return path.join(modulePath, "../../", "/bin/libwebp_linux_arm/bin/webpmux"); //return linux library path
}
return path.join(modulePath, "../../", "/bin/libwebp_linux/bin/webpmux"); //return linux library path
} else if (process.platform === "win32") {
if (process.arch === "x64") {
return path.join(
modulePath,
"../../",
"\\bin\\libwebp_win64\\bin\\webpmux.exe",
); //return windows 64bit library path
} else {
console.log("Unsupported platform:", process.platform, process.arch); //show unsupported platform message
}
} else {
console.log("Unsupported platform:", process.platform, process.arch); //show unsupported platform message
}
};
module.exports = webpmux;