Skip to content

Commit

Permalink
Added more log information to Gd2.php exceptions (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
loekvangool authored Dec 30, 2022
1 parent facc75b commit 3dcbdca
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ private function _getCallback($callbackType, $fileType = null, $unsupportedText
$fileType = $this->_fileType;
}
if (empty(self::$_callbacks[$fileType])) {
throw new Exception($unsupportedText);
throw new Exception("{$unsupportedText}. Type was: {$fileType}. File was: {$this->_fileName}");
}
if (empty(self::$_callbacks[$fileType][$callbackType])) {
throw new Exception('Callback not found.');
throw new Exception("Callback not found. Callbacktype was: {$callbackType}. File was: {$this->_fileName}");
}
return self::$_callbacks[$fileType][$callbackType];
}
Expand All @@ -245,17 +245,17 @@ private function _fillBackgroundColor(&$imageResourceTo)
// fill truecolor png with alpha transparency
if ($isAlpha) {
if (!imagealphablending($imageResourceTo, false)) {
throw new Exception('Failed to set alpha blending for PNG image.');
throw new Exception('Failed to set alpha blending for PNG image. File was: {$this->_fileName}');
}
$transparentAlphaColor = imagecolorallocatealpha($imageResourceTo, 0, 0, 0, 127);
if (false === $transparentAlphaColor) {
throw new Exception('Failed to allocate alpha transparency for PNG image.');
throw new Exception('Failed to allocate alpha transparency for PNG image. File was: {$this->_fileName}');
}
if (!imagefill($imageResourceTo, 0, 0, $transparentAlphaColor)) {
throw new Exception('Failed to fill PNG image with alpha transparency.');
throw new Exception('Failed to fill PNG image with alpha transparency. File was: {$this->_fileName}');
}
if (!imagesavealpha($imageResourceTo, true)) {
throw new Exception('Failed to save alpha transparency into PNG image.');
throw new Exception('Failed to save alpha transparency into PNG image. File was: {$this->_fileName}');
}

return $transparentAlphaColor;
Expand All @@ -281,7 +281,7 @@ private function _fillBackgroundColor(&$imageResourceTo)
list($r, $g, $b) = $this->_backgroundColor;
$color = imagecolorallocate($imageResourceTo, $r, $g, $b);
if (!imagefill($imageResourceTo, 0, 0, $color)) {
throw new Exception("Failed to fill image background with color {$r} {$g} {$b}.");
throw new Exception("Failed to fill image background with color {$r} {$g} {$b}. File was: {$this->_fileName}");
}

return $color;
Expand Down Expand Up @@ -329,7 +329,7 @@ private function _getTransparency($imageResource, $fileType, &$isAlpha = false,
public function resize($frameWidth = null, $frameHeight = null)
{
if (empty($frameWidth) && empty($frameHeight)) {
throw new Exception('Invalid image dimensions.');
throw new Exception('Invalid image dimensions. File was: {$this->_fileName}');
}

// calculate lacking dimension
Expand Down

0 comments on commit 3dcbdca

Please sign in to comment.