Returns the int value for PHP color.

@param resource $im
@return int
333577
public function allocate(&$im) {
        $allocated = imagecolorallocate($im, $this->r, $this->g, $this->b);
        if ($this->transparent) {
            return imagecolortransparent($im, $allocated);
        } else {
            return $allocated;
        }
    }
1323579
public function getInt(string $index, $default = null, array $options = []) : ?int
    {
        return $this->getCastedValue('int', $index, $default, $options);
    }
169216
def getheaderAnim(self, im):
        
        bb = b'GIF89a'
        bb += intToBin(im.size[0])
        bb += intToBin(im.size[1])
        bb += b'\x87\x00\x00'
        return bb
1186190
public function getInt($min = 0, $max = 2147483647)
    {
        /** @noinspection TypeUnsafeComparisonInspection */
        if ($min == $max) {
            return $min;
        } else {
            $ar = unpack('l', $this->getByte(4));
            return $min + abs($ar[1]) % ($max - $min + 1);
        }
    }
1012733
public function colorAt($index) 
    {
        $sampleCount = $this->samples[$index * 5 + self::IDX_COUNT];
        $alphaSum = $this->samples[$index * 5 + self::IDX_A];
        return $sampleCount == 0 || $alphaSum == 0 ? 0 :
            ColorUtils::from(
                (int)($alphaSum / $sampleCount),
                (int)($this->samples[$index * 5 + self::IDX_R] / $alphaSum),
                (int)($this->samples[$index * 5 + self::IDX_G] / $alphaSum),
                (int)($this->samples[$index * 5 + self::IDX_B] / $alphaSum)
            );
    }
403853
public function draw($im) {
        // Starting Code
        $this->drawChar($im, '001100', true);

        // Chars
        $c = strlen($this->text);
        for ($i = 0; $i < $c; $i++) {
            $this->drawChar($im, $this->findCode($this->text[$i]), true);
        }

        // Checksum
        $this->calculateChecksum();
        $c = count($this->checksumValue);
        for ($i = 0; $i < $c; $i++) {
            $this->drawChar($im, $this->code[$this->checksumValue[$i]], true);
        }

        // Ending Code
        $this->drawChar($im, '00110', true);
        $this->drawText($im, 0, 0, $this->positionX, $this->thickness);
    }
200275
protected function getMemoryLimit(): ?int
    {
        $short = [
            'k' => 1024,
            'm' => 1048576,
            'g' => 1073741824,
        ];

        $setting = (string) ini_get('memory_limit');

        if (!($len = strlen($setting))) {
            return null;
        }

        $last = strtolower($setting[$len - 1]);
        $numeric = (int) $setting;
        $numeric *= isset($short[$last]) ? $short[$last] : 1;

        return $numeric;
    }
817138
public function getColorCode($color)
    {
        if (!$this->enabled) {
            return '';
        }
        if (!isset($this->colors[$color])) {
            throw new Exception("No such color $color");
        }

        return $this->colors[$color];
    }
404102
def getheaderAnim(self, im):
        
        bb = "GIF89a"
        bb += intToBin(im.size[0])
        bb += intToBin(im.size[1])
        bb += "\x87\x00\x00"
        return bb
701496
protected function drawChar($im, $code, $startBar = true) {
        $colors = array(CINBarcode::COLOR_FG, CINBarcode::COLOR_BG);
        $currentColor = $startBar ? 0 : 1;
        $c = strlen($code);
        for ($i = 0; $i < $c; $i++) {
            for ($j = 0; $j < intval($code[$i]) + 1; $j++) {
                $this->drawSingleBar($im, $colors[$currentColor]);
                $this->nextX();
            }

            $currentColor = ($currentColor + 1) % 2;
        }
    }
303295
def has_im():
    """"""
    if shutil.which("magick"):
        return ["magick", "convert"]

    if shutil.which("convert"):
        return ["convert"]

    logging.error("Imagemagick wasn't found on your system.")
    logging.error("Try another backend. (wal --backend)")
    sys.exit(1)
306153
protected function drawPixel($im, $x, $y, $color = self::COLOR_FG) {
        $xR = ($x + $this->offsetX) * $this->scale + $this->pushLabel[0];
        $yR = ($y + $this->offsetY) * $this->scale + $this->pushLabel[1];

        // We always draw a rectangle
        imagefilledrectangle($im,
            $xR,
            $yR,
            $xR + $this->scale - 1,
            $yR + $this->scale - 1,
            $this->getColor($im, $color));
    }
995097
protected function getColorScore($color, $count, $colorsCount)
	    {
	        $sRGBComponents = $this->getSRGBComponents($this->getRGBComponents($color));
	        $max 			= max($sRGBComponents);
	        $min 			= min($sRGBComponents);
	        $diff 			= $max - $min;
	        $sum 			= $max + $min;
	        $saturation 	= $diff ? ($sum / 2 > .5 ? $diff / (2 - $diff) : $diff / $sum) : 0;
	        $luminosity 	= ($sum / 2 + .2126 * $sRGBComponents[0] + .7152 * $sRGBComponents[1] + .0722 * $sRGBComponents[2]) / 2;

	        return $saturation < .5 ?
	            (1 - $luminosity) * $count / $colorsCount :
	            $count * ($saturation) * $luminosity;
	    }
1144181
public static function get($value)
    {

        if ($value instanceof ColorInterface)
            return $value;

        if (empty($value))
            return new RgbColor(0,0,0);

        if (is_int($value))
            return self::parseInt($value);

        if ($color = self::parseName($value))
            return $color;

        if ($color = self::parseHexString($value))
            return $color;

        if ($color = self::parseFunctionString($value))
            return $color;

        return null;
    }
744059
public function intVal(): int
    {
        if (!isset($this->_intNum)) {
            $num = gmp_init($this->_num, 10);
            if (gmp_cmp($num, $this->_intMaxGmp()) > 0) {
                throw new \RuntimeException("Integer overflow.");
            }
            if (gmp_cmp($num, $this->_intMinGmp()) < 0) {
                throw new \RuntimeException("Integer underflow.");
            }
            $this->_intNum = gmp_intval($num);
        }
        return $this->_intNum;
    }
1177655
protected function color(&$out)
    {
        $color = [Type::T_COLOR];
        $s     = $this->count;

        if ($this->match('(#([0-9a-f]+))', $m)) {
            $nofValues = strlen($m[2]);
            $hasAlpha  = $nofValues === 4 || $nofValues === 8;
            $channels  = $hasAlpha ? [4, 3, 2, 1] : [3, 2, 1];

            switch ($nofValues) {
                case 3:
                case 4:
                    $num = hexdec($m[2]);

                    foreach ($channels as $i) {
                        $t = $num & 0xf;
                        $color[$i] = $t << 4 | $t;
                        $num >>= 4;
                    }
                    break;

                case 6:
                case 8:
                    $num = hexdec($m[2]);

                    foreach ($channels as $i) {
                        $color[$i] = $num & 0xff;
                        $num >>= 8;
                    }
                    break;

                default:
                    $this->seek($s);

                    return false;
            }

            if ($hasAlpha) {
                if ($color[4] === 255) {
                    $color[4] = 1; // fully opaque
                } else {
                    $color[4] = round($color[4] / 255, 3);
                }
            }

            $out = $color;

            return true;
        }

        return false;
    }
1053933
static public function color($color) {
		if (!is_array($color)) {
			$color = compact('color');
		}

		$color += array('color' => null, 'style' => null, 'background' => null);

		if ($color['color'] == 'reset') {
			return "\033[0m";
		}

		$colors = array();
		foreach (array('color', 'style', 'background') as $type) {
			$code = $color[$type];
			if (isset(self::$_colors[$type][$code])) {
				$colors[] = self::$_colors[$type][$code];
			}
		}

		if (empty($colors)) {
			$colors[] = 0;
		}

		return "\033[" . join(';', $colors) . "m";
	}