WideImage
WideImage copied to clipboard
Wrong $fillColor Inside function resizeInsideRect()
This function has param $fillColor = null abn when is not passed, image is filled black color! Who said that background color must be black and not white or transparent. I expect transparent color and other colors only when is passed.
Something like this:
if ($fillColor) {
if (is_numeric($fillColor)) {
$fillColor = $this->getColorRGB($fillColor);
}
} else {
// $fillColor = $this->getColorRGB($this->getColorAt(0, 0));
}
$rect = WideImage::createTrueColorImage($width, $height);
if($fillColor) {
$rect->fill(0, 0, $rect->allocateColor($fillColor));
} else {
$rect->fill(0, 0, $rect->setTransparentColor(0));
}
Currently, it falls back to the colour of pixel in corner, which sounds reasonable to me. Your image probably has fully-transparent black pixel. The issue is that it does not preserve the alpha.
Does the following change fix your issue?
diff --git a/lib/TrueColorImage.php b/lib/TrueColorImage.php
index 38ce416..c8c4161 100644
--- a/lib/TrueColorImage.php
+++ b/lib/TrueColorImage.php
@@ -285,7 +285,7 @@ class TrueColorImage extends Image
}
$rect = WideImage::createTrueColorImage($width, $height);
- $rect->fill(0, 0, $rect->allocateColor($fillColor));
+ $rect->fill(0, 0, $rect->allocateColorAlpha($fillColor));
$img = $this;
Yes, its correct now.