
ImagickDraw::clone 메서드는 현재 객체의 참조를 반환하는 것이 아니라, 현재 객체를 복제하여 새로운 객체를 반환합니다.
이 메서드는 여러 개의 이미지에 대한 작업을 수행할 때 유용합니다. 예를 들어, 여러 개의 이미지에 대한 작업을 수행할 때, 현재 객체를 복제하여 작업을 수행하는 것이 좋습니다.
다음은 예제입니다.
#hostingforum.kr
php
$draw = new ImagickDraw();
$draw->setFillColor('black');
$draw->setFontSize(24);
$draw->setFont('arial');
$draw->annotation(10, 10, 'Hello, World!');
$cloneDraw = $draw->clone();
$cloneDraw->setFillColor('red');
$cloneDraw->annotation(50, 50, 'Clone');
$image = new Imagick();
$image->newImage(200, 100, 'white');
$image->drawImage($draw);
$image->drawImage($cloneDraw);
$image->writeImage('output.png');
이 예제에서, `$draw` 객체를 복제하여 `$cloneDraw` 객체를 생성합니다. `$cloneDraw` 객체는 `$draw` 객체의 복제본으로, `$draw` 객체의 속성을 변경할 수 있습니다.
이러한 방법은 여러 개의 이미지에 대한 작업을 수행할 때 유용합니다.
2025-04-27 06:55