imagefilltoborder() 테두리 색상이 테두리로 정의되는 특정 색상으로 플러드 채우기를 수행하는 데 사용되는 PHP의 내장 함수입니다. 채우기의 시작점은 (x,y) 또는 왼쪽 상단은 (0, 0)이며 영역은 색상으로 채워집니다.
구문
bool imagefilltoborder(resource $image, int $x, int $y, int $border, int $color)
매개변수
imagefilltoborder() $image, $x, $y, $border 및 $color의 5가지 매개변수를 사용합니다.
-
$이미지 - 이미지 리소스입니다.
-
$x − 시작의 x 좌표를 지정합니다.
-
$y − 시작의 y 좌표를 지정합니다.
-
$테두리 - 테두리 색상을 지정합니다.
-
$color - 색상을 지정합니다.
반환 값
성공하면 True, 실패하면 False를 반환합니다.
예시 1
<?php
// Load the GIF image from local drive folder.
$img = imagecreatefromgif('C:\xampp\htdocs\Images\img39.gif');
// Create the image colors
$borderColor = imagecolorallocate($img, 0, 200, 0);
$fillColor = imagecolorallocate($img, 122, 122, 122);
// Add fill to border
imagefilltoborder($img, 0, 0, $borderColor, $fillColor);
// Show the output image
header('Content-type: image/gif');
imagepng($img);
?> 출력
PHP에서 imagefilltoborder() 함수를 사용하기 전의 GIF 이미지

PHP에서 imagefilltoborder() 함수를 사용한 후의 GIF 이미지

예시 2:타원을 색상으로 채우기
<?php
// Created the image, set the background to gray color
$img = imagecreatetruecolor(700, 500);
imagefilledrectangle($img, 0, 0, 500, 500,imagecolorallocate($img, 122, 122, 122));
// Draw an ellipse to fill with a black border.
imageellipse($img, 300, 300, 300, 300, imagecolorallocate($img, 0, 0, 0));
// Set the border and fill using the blue colors
$border = imagecolorallocate($img, 0, 0, 0);
$fill = imagecolorallocate($img, 0, 0, 255);
// Fill the selection
imagefilltoborder($img, 300, 300, $border, $fill);
// show the output image and free memory
header('Content-type: image/gif');
imagepng($img);
imagedestroy($img);
?> 출력
