이미지 처리 및 GD imagexbm
(PHP 5, PHP 7, PHP 8)
imagexbm — 브라우저 또는 파일에 XBM 이미지 출력
설명
imagexbm(GdImage $image
, ?string $filename
, ?int $foreground_color
= null
): bool
주어진 image
의 XBM 버전을 출력하거나 저장합니다.
참고: imagexbm()은 패딩을 적용하지 않으므로 이미지 너비는 8의 배수여야 합니다. 이 제한은 PHP 7.0.9부터 더 이상 적용되지 않습니다.
매개변수
image
- imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
filename
- 파일을 저장할 경로로, 문자열로 지정됩니다.
null
이면 원시 이미지 스트림이 직접 출력됩니다.filename
(.xbm 확장자 제외)은 XBM의 C 식별자에도 사용되며, 현재 로케일의 영숫자가 아닌 문자는 밑줄로 대체됩니다.filename
이null
로 설정되면 이미지가 C 식별자를 빌드하는 데 사용됩니다. foreground_color
- imagecolorallocate()에서 얻은 식별자를 설정하여 이 매개변수로 전경색을 설정할 수 있습니다. 기본 전경색은 검정색입니다. 다른 모든 색상은 배경으로 처리됩니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
주의 그러나 libgd가 이미지 출력에 실패하면 이 함수는 true
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | image 는 이제 GdImage 인스턴스를 예상환합니다. 이전에는 리소스가 필요했습니다. |
8.0.0 | foreground_color 는 이제 nullable입니다. |
8.0.0 | 사용되지 않은 네 번째 매개변수가 제거되었습니다. |
Examples
예제 #1 XBM 파일 저장
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Save the image
imagexbm($im, 'simpletext.xbm');
// Free up memory
imagedestroy($im);
?>
예제 #2 전경색이 다른 XBM 파일 저장
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Set a replacement foreground color
$foreground_color = imagecolorallocate($im, 255, 0, 0);
// Save the image
imagexbm($im, NULL, $foreground_color);
// Free up memory
imagedestroy($im);
?>