略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Gmagick::quantizeimage

2024-11-14

Gmagick::quantizeimage

(PECL gmagick >= Unknown)

Gmagick::quantizeimageAnalyzes the colors within a reference image

说明

public Gmagick::quantizeimage(
    int $numColors,
    int $colorspace,
    int $treeDepth,
    bool $dither,
    bool $measureError
): Gmagick

Analyzes the colors within a reference image and chooses a fixed number of colors to represent the image. The goal of the algorithm is to minimize the color difference between the input and output image while minimizing the processing time.

参数

numColors

The number of colors.

colorspace

Perform color reduction in this colorspace, typically RGBColorspace.

treeDepth

Normally, this integer value is zero or one. A zero or one tells Quantize to choose a optimal tree depth of Log4(number_colors).% A tree of this depth generally allows the best representation of the reference image with the least amount of memory and the fastest computational speed. In some cases, such as an image with low color dispersion (a few number of colors), a value other than Log4(number_colors) is required. To expand the color tree completely, use a value of 8.

dither

A value other than zero distributes the difference between an original image and the corresponding color reduced algorithm to neighboring pixels along a Hilbert curve.

measureError

A value other than zero measures the difference between the original and quantized images. This difference is the total quantization error. The error is computed by summing over all pixels in an image the distance squared in RGB space between each reference pixel value and its quantized value.

返回值

The Gmagick object on success

错误/异常

错误时抛出 GmagickException

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/gmagick.quantizeimage.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3