I load transparent png image and i every time i try to set bg color using setimagebackgroundcolor()
it still transparent
$input_img = new Imagick();
$input_img->setBackgroundColor("#ff0000");
$input_img->readImage("transparent.png");
$input_img->setimagebackgroundcolor("#00ff00");
$input_img->setImageFormat("png");
$input_img->setimagebackgroundcolor("#ff00ff");
$input_img->writeimage("image.png");
First line of the code sets a new Imagickpixel object for the colors. Second line creates a new frame and 1920 and 1200 is ofcourse the dimensions.
$color = new ImagickPixel("white");
$input_img->newImage(1920,1200, $color)
The trick is using: $im = $im->flattenImages();
:
<?php
$im = new Imagick($filename);
$im->setImageBackgroundColor('#ffffff');
$im = $im->flattenImages();
$im->setImageFormat("jpeg");
$im->setImageCompressionQuality(95);
$im->writeImage($filename);
Try this!
$imput_img->setBackgroundColor(new ImagickPixel('blue'));