Skip to content

Commit

Permalink
ACP2E-3127: imagecreatetruecolor(): Argument #2 () must be greater th…
Browse files Browse the repository at this point in the history
…an 0. Can't upload specific image
  • Loading branch information
Chhandak.Barua authored and Chhandak.Barua committed Jul 30, 2024
1 parent 6ba4ce9 commit 3a1a00d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
17 changes: 9 additions & 8 deletions app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,15 @@ public function resizeFile($source, $keepRatio = true)
$image->keepAspectRatio($keepRatio);

[$imageWidth, $imageHeight] = $this->getResizedParams($source);
try {
$image->resize($imageWidth, $imageHeight);
} catch (\Throwable $e) {
$this->logger->critical(
'FAILED WYSIWYG IMAGE RESIZING: ' . ' error: ' . $e->getMessage() . '. path: ' . $realPath
);
return false;
}
$image->resize($imageWidth, $imageHeight);
// try {
// $image->resize($imageWidth, $imageHeight);
// } catch (\Throwable $e) {
// $this->logger->critical(
// 'FAILED WYSIWYG IMAGE RESIZING: ' . ' error: ' . $e->getMessage() . '. path: ' . $realPath
// );
// return false;
// }
$dest = $targetDir . '/' . $this->ioFile->getPathInfo($source)['basename'];
$image->save($dest);
if ($this->_directory->isFile($this->_directory->getRelativePath($dest))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,10 @@ protected function _checkAspectRatio($frameWidth, $frameHeight)
}
// keep aspect ratio
if ($this->_imageSrcWidth / $this->_imageSrcHeight >= $frameWidth / $frameHeight) {
$dstHeight = round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight);
$dstHeight = max(
1,
round($dstWidth / $this->_imageSrcWidth * $this->_imageSrcHeight)
);
} else {
$dstWidth = round($dstHeight / $this->_imageSrcHeight * $this->_imageSrcWidth);
}
Expand Down

0 comments on commit 3a1a00d

Please sign in to comment.