This commit is contained in:
Yuri Kuznetsov
2025-03-26 13:34:21 +02:00
parent e92b200eb3
commit 41b0dd4e78
39 changed files with 92 additions and 85 deletions
+6 -1
View File
@@ -48,6 +48,7 @@ use Espo\Core\Utils\Metadata;
use Espo\Entities\Attachment;
use GdImage;
use RuntimeException;
use Throwable;
class Image implements EntryPoint
@@ -258,6 +259,10 @@ class Image implements EntryPoint
}
}
if ($targetWidth < 1 || $targetHeight < 1) {
throw new RuntimeException("No width or height.");
}
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
if ($targetImage === false) {
@@ -378,7 +383,7 @@ class Image implements EntryPoint
$orientation = $this->getOrientation($filePath);
if ($orientation) {
$angle = array_values([0, 0, 0, 180, 0, 0, -90, 0, 90])[$orientation];
$angle = [0, 0, 0, 180, 0, 0, -90, 0, 90][$orientation];
$targetImage = imagerotate($targetImage, $angle, 0) ?: $targetImage;
}