2014-06-18 3 views
0

Imagick과 PHP에 처음 사용되었습니다. 내가 원하는 것은 그레이 스케일 그라디언트에 RGB 색상을 넣는 것입니다.PHP Imagick 색상 그레이 스케일 그래디언트

입력 :

Input

출력 :

enter image description here

출력 색상이 상이 할 수있다. 어떤 아이디어라도 도움이 될 것입니다.

미리 감사드립니다. 인사말,

답변

2

당신이 요청한 것을 할 수있는 colorizeImage 함수가 있습니다.

function colorizeImage($imagePath, $color, $opacity) { 
    $imagick = new \Imagick(realpath($imagePath)); 
    //TBH - not sure if opacity is meant to be on the color or colorize call 
    //neither seem to have much effect. 
    $opacity = $opacity/255.0; 
    $opacityColor = new \ImagickPixel("rgba(0, 0, 0, $opacity)"); 
    $imagick->colorizeImage($color, $opacityColor); 
    header("Content-Type: image/jpg"); 
    echo $imagick->getImageBlob(); 
} 


$color = "rgb(252, 38, 231)"; 
$opacity = 0.5 
colorizeImage("someImage.png", $color, opacity); 

그러나 왜 그렇게하고 싶습니까? 색상화된 그라데이션을 직접 만들면됩니다.

$opacity = new \Imagick(); 
$opacity->newPseudoImage(100, 50, "gradient:rgb(255,128,128,0.5)-none"); 

//Gradients are created down 
$opacity->rotateimage('black', 90); 

이는 한 단계에서 완벽한 그라디언트를 만듭니다.

관련 문제