Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -289,8 +289,10 @@ async function downloadImage(image, tempDir, instanceID) {
|
|
| 289 |
const imagePath = path.join(tempDir, `image_${instanceID}_${Date.now()}_${Math.floor(Math.random() * 1000)}.jpg`);
|
| 290 |
await writeFileAsync(imagePath, response.data);
|
| 291 |
|
|
|
|
| 292 |
const imageHeight = await getImageHeight(imagePath);
|
| 293 |
-
const
|
|
|
|
| 294 |
await execPromise(command);
|
| 295 |
|
| 296 |
return imagePath;
|
|
@@ -309,7 +311,7 @@ async function processImages(imgList, tempDir, instanceID) {
|
|
| 309 |
const imagePath = await downloadImage(imgList[i], tempDir, instanceID);
|
| 310 |
partImages.push(imagePath);
|
| 311 |
|
| 312 |
-
if (await getTotalHeight(partImages) >
|
| 313 |
await combineAndSave(partImages, partIndex, tempDir);
|
| 314 |
partImages = [];
|
| 315 |
partIndex++;
|
|
|
|
| 289 |
const imagePath = path.join(tempDir, `image_${instanceID}_${Date.now()}_${Math.floor(Math.random() * 1000)}.jpg`);
|
| 290 |
await writeFileAsync(imagePath, response.data);
|
| 291 |
|
| 292 |
+
// Mengurangi ukuran gambar sekitar 30%
|
| 293 |
const imageHeight = await getImageHeight(imagePath);
|
| 294 |
+
const newHeight = Math.floor(imageHeight * 0.7);
|
| 295 |
+
const command = `convert ${imagePath} -resize 720x${newHeight}! -quality 75 -background white -gravity center -extent 720x${newHeight} ${imagePath}`;
|
| 296 |
await execPromise(command);
|
| 297 |
|
| 298 |
return imagePath;
|
|
|
|
| 311 |
const imagePath = await downloadImage(imgList[i], tempDir, instanceID);
|
| 312 |
partImages.push(imagePath);
|
| 313 |
|
| 314 |
+
if (await getTotalHeight(partImages) > 64000) {
|
| 315 |
await combineAndSave(partImages, partIndex, tempDir);
|
| 316 |
partImages = [];
|
| 317 |
partIndex++;
|