Skip to content

Commit 3a1a00d

Browse files
Chhandak.BaruaChhandak.Barua
Chhandak.Barua
authored and
Chhandak.Barua
committed
ACP2E-3127: imagecreatetruecolor(): Argument #2 () must be greater than 0. Can't upload specific image
1 parent 6ba4ce9 commit 3a1a00d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,15 @@ public function resizeFile($source, $keepRatio = true)
722722
$image->keepAspectRatio($keepRatio);
723723

724724
[$imageWidth, $imageHeight] = $this->getResizedParams($source);
725-
try {
726-
$image->resize($imageWidth, $imageHeight);
727-
} catch (\Throwable $e) {
728-
$this->logger->critical(
729-
'FAILED WYSIWYG IMAGE RESIZING: ' . ' error: ' . $e->getMessage() . '. path: ' . $realPath
730-
);
731-
return false;
732-
}
725+
$image->resize($imageWidth, $imageHeight);
726+
// try {
727+
// $image->resize($imageWidth, $imageHeight);
728+
// } catch (\Throwable $e) {
729+
// $this->logger->critical(
730+
// 'FAILED WYSIWYG IMAGE RESIZING: ' . ' error: ' . $e->getMessage() . '. path: ' . $realPath
731+
// );
732+
// return false;
733+
// }
733734
$dest = $targetDir . '/' . $this->ioFile->getPathInfo($source)['basename'];
734735
$image->save($dest);
735736
if ($this->_directory->isFile($this->_directory->getRelativePath($dest))) {

lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ protected function _checkAspectRatio($frameWidth, $frameHeight)
604604
}
605605
// keep aspect ratio
606606
if ($this->_imageSrcWidth / $this->_imageSrcHeight >= $frameWidth / $frameHeight) {
607-
$dstHeight = round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight);
607+
$dstHeight = max(
608+
1,
609+
round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight)
610+
);
608611
} else {
609612
$dstWidth = round($dstHeight / $this->_imageSrcHeight * $this->_imageSrcWidth);
610613
}

0 commit comments

Comments
 (0)