
Imagick::getSamplingFactors 함수는 이미지 다운 샘플링 시 사용하는 가중치를 반환하는 함수입니다.
이미지 다운 샘플링 시 가중치는 다음과 같이 계산됩니다.
- 가로 방향 downsampling: (1/2)^x, x는 downsampling 횟수입니다.
- 세로 방향 downsampling: (1/2)^y, y는 downsampling 횟수입니다.
예를 들어, 가로 방향 downsampling이 2번, 세로 방향 downsampling이 3번인 경우 가중치는 다음과 같습니다.
- 가로 방향 downsampling: (1/2)^2 = 1/4
- 세로 방향 downsampling: (1/2)^3 = 1/8
따라서, 가중치는 1/4 * 1/8 = 1/32입니다.
Imagick::getSamplingFactors 함수를 사용하여 가중치를 얻을 수 있습니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$samplingFactors = $im->getSamplingFactors();
$horizontalFactor = pow(2, -$samplingFactors[0]);
$verticalFactor = pow(2, -$samplingFactors[1]);
$weight = $horizontalFactor * $verticalFactor;
이러한 가중치는 이미지 다운 샘플링 시 사용되는 가중치입니다.
2025-05-20 15:45