问题
I've this gif:
https://dl.dropboxusercontent.com/u/76885657/stackoverflow/2.gif
(transparent background)
And with this code:
$im = new Imagick();
$im->readimage("example.gif");
$im->setImageAlphaChannel(11);
$im->setImageBackgroundColor('white');
$im->setImageFormat("jpg");
$im->stripImage();
$im->writeImage("example.jpg");
$im->clear();
$im->destroy();
Results:
https*://dl.dropboxusercontent.com/u/76885657/stackoverflow/3.jpg(without *)
(gold background)
But want this:
https://dl.dropboxusercontent.com/u/76885657/stackoverflow/2.jpg
(white background)
回答1:
I've found it. Was the order!:
$im = new Imagick();
$im->readimage("example.gif");
// Wrong
$im->setImageBackgroundColor('white');
$im->setImageAlphaChannel(11);
// Write!!!
$im->setImageAlphaChannel(11);
$im->setImageBackgroundColor('white');
// Rest of code...
$im->setImageFormat("jpg");
$im->stripImage();
$im->writeImage("example.jpg");
$im->clear();
$im->destroy();
来源:https://stackoverflow.com/questions/28154179/php-imagick-gif-to-jpg-background