2011-04-19 2 views
1

이미지 관점을 설정하려고합니다. 빈 다각형이있는 랩톱 이미지가 있습니다. enter image description hereimagick :: distortimage

빈 영역에 다른 이미지를 가져와야합니다. 이처럼 :

$controlPoints = array(0, 0, 
          0, 0, 
          0, $im->getImageHeight(), 
          0, $im->getImageHeight(), 
          $im->getImageWidth(), 0, 
          $im->getImageWidth(), 0, 
          $im->getImageWidth(), $im->getImageHeight(), 
          $im->getImageWidth(), $im->getImageHeight()); 
    /* Perform the distortion */ 
    $im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true); 

가 어떻게 $ 제어점 배열을 설정할 수 있습니다 : 그래서 enter image description here

, 나는 동적 왜곡이 코드가? 이미지의 각 구석에 4 개의 좌표를 설정할 수는 없습니까? 불행히도, imageick :: 왜곡 이미지에 대한 문서는 좋지 않습니다.

문제는 또 다른 변형 방법을 이용함으로써 해결된다

$im->cropImage(125, 121, $center_x, $center_y); 
    $controlPoints = array(
        0,0, 35,20, # top left 
        190,0, 150,30, # top right 
        0,205, -16,105, # bottom right 
        176,135, 115,105 # bottum left 
        ); 
    /* Perform the distortion */ 
    $im->distortImage(Imagick::DISTORTION_BILINEAR, $controlPoints, true); 

답변

8

제어 포인트는 필요한만큼을 4 쌍 수 있지만, 최소 3 쌍한다. 제어점의 의미는 입니다. source_x, source_y, destination_x, destination_y

기본적으로 소스 이미지의 점이 대상 이미지의 어디에 있어야하는지 알려줍니다. 각 목적지 좌표 위의 배열에 교체 파악해야합니다, 분명히

$controlPoints = array(
    0, 0, <destination_x>, <destination_y>, 
    0, $im->getImageHeight(), <destination_x>, <destination_y>, 
    $im->getImageWidth(), 0, <destination_x>, <destination_y>, 
    $im->getImageWidth(), $im->getImageHeight(), <destination_x>, <destination_y> 
); 

:

는 귀하의 경우에 당신은 4쌍, 사각형의 각 모서리 하나가 필요합니다.

관련 문제