Spaces:
Runtime error
Runtime error
Update egg-api.js
#1
by
mmdhx
- opened
- egg-api.js +7 -8
egg-api.js
CHANGED
|
@@ -70,11 +70,6 @@ async function videoToGif(inputVideoPath, outputGifPath) {
|
|
| 70 |
.run();
|
| 71 |
});
|
| 72 |
}
|
| 73 |
-
// 下载并转换图片到内存的辅助函数
|
| 74 |
-
async function downloadAndConvertImage(url) {
|
| 75 |
-
const response = await axios.get(url, { responseType: 'arraybuffer' });
|
| 76 |
-
return await Jimp.read(response.data);
|
| 77 |
-
}
|
| 78 |
|
| 79 |
// 处理图片的 Express 接口
|
| 80 |
app.get('/process-image', async (req, res) => {
|
|
@@ -173,7 +168,9 @@ app.get('/process-image', async (req, res) => {
|
|
| 173 |
} else {
|
| 174 |
// 删除临时文件
|
| 175 |
fs.unlinkSync(tempImagePath);
|
| 176 |
-
fs.
|
|
|
|
|
|
|
| 177 |
fs.unlinkSync(outputImagePath);
|
| 178 |
}
|
| 179 |
});
|
|
@@ -223,7 +220,7 @@ app.get('/processGif', async (req, res) => {
|
|
| 223 |
writer.on('finish', resolve);
|
| 224 |
writer.on('error', reject);
|
| 225 |
});
|
| 226 |
-
replacementImageBuffer=await Jimp.read(tempGifPaths)
|
| 227 |
}
|
| 228 |
console.log('GIF下载完成:', tempGifPath);
|
| 229 |
|
|
@@ -294,7 +291,9 @@ app.get('/processGif', async (req, res) => {
|
|
| 294 |
} else {
|
| 295 |
// 删除临时文件
|
| 296 |
fs.unlinkSync(tempGifPath);
|
| 297 |
-
fs.
|
|
|
|
|
|
|
| 298 |
fs.unlinkSync(tempVideoPath);
|
| 299 |
fs.unlinkSync(outputGifPath);
|
| 300 |
}
|
|
|
|
| 70 |
.run();
|
| 71 |
});
|
| 72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
// 处理图片的 Express 接口
|
| 75 |
app.get('/process-image', async (req, res) => {
|
|
|
|
| 168 |
} else {
|
| 169 |
// 删除临时文件
|
| 170 |
fs.unlinkSync(tempImagePath);
|
| 171 |
+
if (fs.existsSync(tempImagePaths)) {
|
| 172 |
+
fs.unlinkSync(tempImagePaths);
|
| 173 |
+
}
|
| 174 |
fs.unlinkSync(outputImagePath);
|
| 175 |
}
|
| 176 |
});
|
|
|
|
| 220 |
writer.on('finish', resolve);
|
| 221 |
writer.on('error', reject);
|
| 222 |
});
|
| 223 |
+
replacementImageBuffer = await Jimp.read(tempGifPaths)
|
| 224 |
}
|
| 225 |
console.log('GIF下载完成:', tempGifPath);
|
| 226 |
|
|
|
|
| 291 |
} else {
|
| 292 |
// 删除临时文件
|
| 293 |
fs.unlinkSync(tempGifPath);
|
| 294 |
+
if (fs.existsSync(tempGifPaths)) {
|
| 295 |
+
fs.unlinkSync(tempGifPaths);
|
| 296 |
+
}
|
| 297 |
fs.unlinkSync(tempVideoPath);
|
| 298 |
fs.unlinkSync(outputGifPath);
|
| 299 |
}
|