이미지 처리 및 GD imagesavealpha
(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)
imagesavealpha — PNG 이미지를 저장할 때 전체 알파 채널 정보를 유지할지 여부
설명
imagesavealpha(GdImage $image
, bool $enable
): bool
imagesavealpha()는 PNG 이미지를 저장할 때 전체 알파 채널 정보(단일 색상 투명도와 반대)를 유지할지 여부를 결정하는 플래그를 설정합니다.
처음에 알파 채널을 유지하려면 알파 블렌딩을 비활성화해야 합니다(imagealphablending($im, false)
).
매개변수
image
- imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
enable
- 알파 채널을 저장할지 여부입니다. 기본값은
false
입니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | image 는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다. |
Examples
예제 #1 기본 imagesavealpha() 사용법
<?php
// Load a png image with alpha channel
$png = imagecreatefrompng('./alphachannel_example.png');
// Turn off alpha blending
imagealphablending($png, false);
// Do desired operations
// Set alpha flag
imagesavealpha($png, true);
// Output image to browser
header('Content-Type: image/png');
imagepng($png);
imagedestroy($png);
?>
기타
- imagealphablending() - 이미지의 혼합 모드 설정