Spaces:
Paused
Paused
Update lib/convertFormat.js
Browse files3 unmodified lines456789101112131415161718 unmodified lines3637383940414216 unmodified lines5960616263646516 unmodified lines828384858687883 unmodified linesconst FileType = require('file-type');const { exec } = require("child_process");if (!fs.existsSync(".tmp")) fs.mkdirSync(".tmp");function imageToWebp(bufferImage) {return new Promise((resolve, reject) => {FileType.fromBuffer(bufferImage).then((response) => {try {const pathFile = ".tmp/" + Math.floor(Math.random() * 1000000 + 1) + "." + response.ext;fs.writeFileSync(pathFile, bufferImage);exec(`cwebp -q 50 ${pathFile} -o ${pathFile}.webp`, (error, stdout, stderr) => {if (!fs.existsSync(pathFile + ".webp")) {18 unmodified linesfunction webpToJpg(bufferImage) {return new Promise((resolve, reject) => {try {const pathFile = ".tmp/" + Math.floor(Math.random() * 1000000 + 1) + ".webp";fs.writeFileSync(pathFile, bufferImage);exec(`dwebp ${pathFile} -o ${pathFile}.jpg`, (error, stdout, stderr) => {16 unmodified linesfunction gifToWebp(bufferImage) {return new Promise((resolve, reject) => {try {const pathFile = ".tmp/" + Math.floor(Math.random() * 1000000 + 1) + ".gif";fs.writeFileSync(pathFile, bufferImage);exec(`gif2webp ${pathFile} -o ${pathFile}.webp`, (error, stdout, stderr) => {16 unmodified linesfunction webpToVideo(bufferImage) {return new Promise((resolve, reject) => {try {const pathFile = ".tmp/" + Math.floor(Math.random() * 1000000 + 1) + ".webp";fs.writeFileSync(pathFile, bufferImage);exec(`convert ${pathFile} ${pathFile}.gif`, (error, stdout, stderr) => {3 unmodified lines456789101112131415161718 unmodified lines3637383940414216 unmodified lines5960616263646516 unmodified lines828384858687883 unmodified linesconst FileType = require('file-type');const { exec } = require("child_process");if (!fs.existsSync("./tmp")) fs.mkdirSync("./tmp");function imageToWebp(bufferImage) {return new Promise((resolve, reject) => {FileType.fromBuffer(bufferImage).then((response) => {try {const pathFile = "./tmp/" + Math.floor(Math.random() * 1000000 + 1) + "." + response.ext;fs.writeFileSync(pathFile, bufferImage);exec(`cwebp -q 50 ${pathFile} -o ${pathFile}.webp`, (error, stdout, stderr) => {if (!fs.existsSync(pathFile + ".webp")) {18 unmodified linesfunction webpToJpg(bufferImage) {return new Promise((resolve, reject) => {try {const pathFile = "./tmp/" + Math.floor(Math.random() * 1000000 + 1) + ".webp";fs.writeFileSync(pathFile, bufferImage);exec(`dwebp ${pathFile} -o ${pathFile}.jpg`, (error, stdout, stderr) => {16 unmodified linesfunction gifToWebp(bufferImage) {return new Promise((resolve, reject) => {try {const pathFile = "./tmp/" + Math.floor(Math.random() * 1000000 + 1) + ".gif";fs.writeFileSync(pathFile, bufferImage);exec(`gif2webp ${pathFile} -o ${pathFile}.webp`, (error, stdout, stderr) => {16 unmodified linesfunction webpToVideo(bufferImage) {return new Promise((resolve, reject) => {try {const pathFile = "./tmp/" + Math.floor(Math.random() * 1000000 + 1) + ".webp";fs.writeFileSync(pathFile, bufferImage);exec(`convert ${pathFile} ${pathFile}.gif`, (error, stdout, stderr) => {
lib/convertFormat.js+5-5