Я хочу преобразовать альфа-прозрачное изображение PNG в изображение PNG на основе палитры.
В GD я могу сделать это легко:
// We have already the image loaded in $source_img
$w=200; $h=200; // We supose that img dimensions are 200x200
$img = imagecreatetruecolor($w, $h); // New black image
list($r, $g, $b) = array(200, 200, 200); // Some color that doesn't appear in image to avoid conflict
$color = imagecolorallocate($img, $r, $g, $b);
imagefill($img, 0, 0, $color); // Fill the black image with the chosen color.
imagecolortransparent($img, $color); // Set the chosen color as transparent
$res = imagecopyresampled($img, $source_img, 0, 0, 0, 0, $w, $h, $w, $h);
Но в Imagick я не знаю, как установить прозрачный цвет (imagecolortransparent () в GD). Я потратил часы на поиск в Интернете, но помощь на сайте php не очень обширна, и есть много недокументированных функций.
Спасибо.