Skip to content

Commit

Permalink
fix(icons): make sure transparent images have a white background
Browse files Browse the repository at this point in the history
There was a difference between GD and Imagick
  • Loading branch information
jeabakker committed Jul 10, 2023
1 parent c4ad503 commit 25d039b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion engine/classes/Elgg/ImageService.php
Expand Up @@ -118,7 +118,12 @@ public function resize(string $source, string $destination = null, array $params
}

$target_size = new Box($max_width, $max_height);
$thumbnail = $image->resize($target_size);
$image->resize($target_size);

// create new canvas with a background (default: white)
$background_color = elgg_extract('background_color', $params, 'ffffff');
$thumbnail = $this->imagine->create($image->getSize(), $image->palette()->color($background_color));
$thumbnail->paste($image, new Point(0, 0));

if (pathinfo($destination, PATHINFO_EXTENSION) === 'webp') {
$options = [
Expand Down

0 comments on commit 25d039b

Please sign in to comment.