@gallop.software/studio 2.3.98 → 2.3.100

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.
@@ -11,7 +11,7 @@
11
11
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
12
12
  }
13
13
  </style>
14
- <script type="module" crossorigin src="/assets/index-WJGbVIOp.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-DelreZW5.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-DfPQBmNf.css">
16
16
  </head>
17
17
  <body>
@@ -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
- let rotatedBuffer;
4488
- let rotatedWidth;
4489
- let rotatedHeight;
4490
- if (rotation !== 0) {
4491
- rotatedBuffer = await sharp7(exifCorrectedBuffer).rotate(rotation).toBuffer();
4492
- if (rotation === 90 || rotation === 270) {
4493
- rotatedWidth = exifHeight;
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 (resize.width !== cropWidth || resize.height !== cropHeight) {
4518
- croppedPipeline = croppedPipeline.resize(resize.width, resize.height);
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 croppedPipeline.png({ quality: 85 }).toBuffer();
4507
+ finalBuffer = await pipeline.png({ quality: 85 }).toBuffer();
4524
4508
  } else if (ext === ".webp") {
4525
- finalBuffer = await croppedPipeline.webp({ quality: 85 }).toBuffer();
4509
+ finalBuffer = await pipeline.webp({ quality: 85 }).toBuffer();
4526
4510
  } else if (ext === ".gif") {
4527
- finalBuffer = await croppedPipeline.gif().toBuffer();
4511
+ finalBuffer = await pipeline.gif().toBuffer();
4528
4512
  } else {
4529
- finalBuffer = await croppedPipeline.jpeg({ quality: 85 }).toBuffer();
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;