@gallop.software/studio 2.3.98 → 2.3.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/index.js +14 -30
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -4484,49 +4484,33 @@ async function handleEditImage(request) {
|
|
|
4484
4484
|
const exifMeta = await sharp7(exifCorrectedBuffer).metadata();
|
|
4485
4485
|
const exifWidth = exifMeta.width || 0;
|
|
4486
4486
|
const exifHeight = exifMeta.height || 0;
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
rotatedHeight = exifWidth;
|
|
4495
|
-
} else {
|
|
4496
|
-
rotatedWidth = exifWidth;
|
|
4497
|
-
rotatedHeight = exifHeight;
|
|
4498
|
-
}
|
|
4499
|
-
} else {
|
|
4500
|
-
rotatedBuffer = exifCorrectedBuffer;
|
|
4501
|
-
rotatedWidth = exifWidth;
|
|
4502
|
-
rotatedHeight = exifHeight;
|
|
4503
|
-
}
|
|
4504
|
-
const cropX = Math.max(0, Math.min(crop.x, rotatedWidth - 1));
|
|
4505
|
-
const cropY = Math.max(0, Math.min(crop.y, rotatedHeight - 1));
|
|
4506
|
-
const cropWidth = Math.min(crop.width, rotatedWidth - cropX);
|
|
4507
|
-
const cropHeight = Math.min(crop.height, rotatedHeight - cropY);
|
|
4508
|
-
let croppedPipeline = sharp7(rotatedBuffer);
|
|
4509
|
-
if (cropX > 0 || cropY > 0 || cropWidth < rotatedWidth || cropHeight < rotatedHeight) {
|
|
4510
|
-
croppedPipeline = croppedPipeline.extract({
|
|
4487
|
+
const cropX = Math.max(0, Math.min(crop.x, exifWidth - 1));
|
|
4488
|
+
const cropY = Math.max(0, Math.min(crop.y, exifHeight - 1));
|
|
4489
|
+
const cropWidth = Math.min(crop.width, exifWidth - cropX);
|
|
4490
|
+
const cropHeight = Math.min(crop.height, exifHeight - cropY);
|
|
4491
|
+
let pipeline = sharp7(exifCorrectedBuffer);
|
|
4492
|
+
if (cropX > 0 || cropY > 0 || cropWidth < exifWidth || cropHeight < exifHeight) {
|
|
4493
|
+
pipeline = pipeline.extract({
|
|
4511
4494
|
left: Math.round(cropX),
|
|
4512
4495
|
top: Math.round(cropY),
|
|
4513
4496
|
width: Math.round(cropWidth),
|
|
4514
4497
|
height: Math.round(cropHeight)
|
|
4515
4498
|
});
|
|
4516
4499
|
}
|
|
4517
|
-
if (
|
|
4518
|
-
|
|
4500
|
+
if (rotation !== 0) {
|
|
4501
|
+
pipeline = pipeline.rotate(rotation);
|
|
4519
4502
|
}
|
|
4503
|
+
pipeline = pipeline.resize(resize.width, resize.height);
|
|
4520
4504
|
const ext = path10.extname(imagePath).toLowerCase();
|
|
4521
4505
|
let finalBuffer;
|
|
4522
4506
|
if (ext === ".png") {
|
|
4523
|
-
finalBuffer = await
|
|
4507
|
+
finalBuffer = await pipeline.png({ quality: 85 }).toBuffer();
|
|
4524
4508
|
} else if (ext === ".webp") {
|
|
4525
|
-
finalBuffer = await
|
|
4509
|
+
finalBuffer = await pipeline.webp({ quality: 85 }).toBuffer();
|
|
4526
4510
|
} else if (ext === ".gif") {
|
|
4527
|
-
finalBuffer = await
|
|
4511
|
+
finalBuffer = await pipeline.gif().toBuffer();
|
|
4528
4512
|
} else {
|
|
4529
|
-
finalBuffer = await
|
|
4513
|
+
finalBuffer = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
4530
4514
|
}
|
|
4531
4515
|
const finalMeta = await sharp7(finalBuffer).metadata();
|
|
4532
4516
|
const finalWidth = finalMeta.width || resize.width;
|