PHP Class ColorThief\ColorThief

Mostrar archivo Open project: ksubileau/color-thief-php Class Usage Examples

Public Methods

Method Description
getColor ( mixed $sourceImage, integer $quality = 10, array $area = null ) : array | boolean Use the median cut algorithm to cluster similar colors.
getColorIndex ( integer $red, integer $green, integer $blue, integer $sigBits = self::SIGBITS ) : integer Get reduced-space color index for a pixel
getColorsFromIndex ( integer $index, integer $rightShift = self::RSHIFT, integer $sigBits = 8 ) : array Get red, green and blue components from reduced-space color index for a pixel
getPalette ( mixed $sourceImage, integer $colorCount = 10, integer $quality = 10, array $area = null ) : array Use the median cut algorithm to cluster similar colors.
naturalOrder ( integer $a, integer $b ) : integer Natural sorting

Protected Methods

Method Description
isClearlyVisible ( object $color ) : boolean
isNonWhite ( object $color ) : boolean

Private Methods

Method Description
doCut ( string $color, VBox $vBox, array $partialSum, integer $total ) : array
getHisto ( array $pixels ) : array Histo: 1-d array, giving the number of pixels in each quantized region of color space
getVBoxColorRanges ( VBox $vBox, array $order ) : array
loadImage ( mixed $sourceImage, integer $quality, array $area = null ) : SplFixedArray
medianCutApply ( array $histo, VBox $vBox ) : array | void
quantize ( SplFixedArra\SplFixedArray | array $pixels, $maxColors ) : boolean | CMap
quantizeIter ( colorthief\PQueue &$priorityQueue, float $target, array $histo ) Inner function to do the iteration
rearrangeColors ( array $order, integer $color1, integer $color2, integer $color3 ) : array
sumColors ( string $axis, array $histo, VBox $vBox ) : array Find the partial sum arrays along the selected axis.
vboxFromHistogram ( array $histo ) : VBox

Method Details

getColor() public static method

Use the median cut algorithm to cluster similar colors.
public static getColor ( mixed $sourceImage, integer $quality = 10, array $area = null ) : array | boolean
$sourceImage mixed Path/URL to the image, GD resource, Imagick instance, or image as binary string
$quality integer 1 is the highest quality. There is a trade-off between quality and speed. The bigger the number, the faster the palette generation but the greater the likelihood that colors will be missed.
$area array
return array | boolean

getColorIndex() public static method

Get reduced-space color index for a pixel
public static getColorIndex ( integer $red, integer $green, integer $blue, integer $sigBits = self::SIGBITS ) : integer
$red integer
$green integer
$blue integer
$sigBits integer
return integer

getColorsFromIndex() public static method

Get red, green and blue components from reduced-space color index for a pixel
public static getColorsFromIndex ( integer $index, integer $rightShift = self::RSHIFT, integer $sigBits = 8 ) : array
$index integer
$rightShift integer
$sigBits integer
return array

getPalette() public static method

Use the median cut algorithm to cluster similar colors.
public static getPalette ( mixed $sourceImage, integer $colorCount = 10, integer $quality = 10, array $area = null ) : array
$sourceImage mixed Path/URL to the image, GD resource, Imagick instance, or image as binary string
$colorCount integer It determines the size of the palette; the number of colors returned.
$quality integer 1 is the highest quality.
$area array
return array

isClearlyVisible() protected static method

protected static isClearlyVisible ( object $color ) : boolean
$color object
return boolean

isNonWhite() protected static method

protected static isNonWhite ( object $color ) : boolean
$color object
return boolean

naturalOrder() public static method

Natural sorting
public static naturalOrder ( integer $a, integer $b ) : integer
$a integer
$b integer
return integer