-
Notifications
You must be signed in to change notification settings - Fork 263
Open
Description
Is there a way to make the method use transparent background (or preserve it from original image) for the padded output image?
// this will show image with white background:
$thumb = new GD($imgPath);
$thumb->resize(40, 40);
$thumb->pad(40, 40, [255, 255, 255]);
$thumb->save($thumbFilePath);
// this (I WOULD LIKE) will show image with transparent background:
$thumb = new GD($imgPath);
$thumb->resize(40, 40);
$thumb->pad(40, 40, false); // or any other call format to specify we wont transparent background
$thumb->save($thumbFilePath);
this is how i patched GD class, i don't know if it is the correct way, also tried with preserveAlpha with no result!
// near line 147
if (!$color) {
imagealphablending($this->workingImage, false);
$fillColor = imagecolorallocatealpha($this->workingImage, 0, 0, 0, 127);
imagefill($this->workingImage, 0, 0, $fillColor);
imagesavealpha($this->workingImage, true);
} else {
// create the fill color
$fillColor = imagecolorallocate(
$this->workingImage, $color[0], $color[1], $color[2]
);
// fill our working image with the fill color
imagefill(
$this->workingImage, 0, 0, $fillColor
);
}
Metadata
Metadata
Assignees
Labels
No labels