Detects if the binary buffer of this image is empty after conversion to two-colors mode.

Empty buffer may mean that the conversion failed.

@param double $threshold The threshold.
@return bool True if empty, false otherwise.
19456
public function isBinaryBufferEmpty($threshold = 0.01) {
		$bin = $this->getBinaryBuffer();
		// delete all empty bytes
		if(strlen(trim($bin, chr(255))) / strlen($bin) < $threshold || strlen(trim($bin, chr(0))) / strlen($bin) < $threshold) {
			// something is wrong, image is filled (almost) solid color.
			return true;
		}
		return false;
	}
444090
public function setComponentThreshold($threshold)
  {
    if (ThrottlerHelper::compareThresholds($threshold, $this->getGlobalThreshold())
        && ThrottlerHelper::validateComponentThreshold($threshold)
        && !$this->isActive())
    {
      $this->componentThreshold = $threshold;
      return true;
    }
    return false;
  }
565776
public function isEmpty($value): bool
    {
        foreach ($value->getDefinition()->getFields() as $name => $field) {
            if (!$field->isEmpty($value->{$name})) {
                return false;
            }
        }

        return true;
    }
267182
public function checkTypeRestriction($target) : bool
    {
        if (empty($this->type)){
            return true;
        }
        static $type_check_funcs = [
            'string' => 'is_string',
            'integer' => 'is_int',
            'int' => 'is_int',
            'float' => 'is_float',
            'double' => 'is_float',
            'boolean' => 'is_bool',
            'bool' => 'is_bool',
            'array' => 'is_array',
            'object' => 'is_object',
            'resource' => 'is_resource',
            'NULL' => 'is_null',
            'null' => 'is_null',
        ];
        $func = $type_check_funcs[$this->type] ?? null;
        if (!$func){
            return true;
        }
        return $func($target);
    }
1059388
public function isEmpty(array $exclude = array())
    {
        $states = $this->getValues();

        foreach($exclude as $state) {
            unset($states[$state]);
        }

        return (bool) (count($states) == 0);
    }
543570
protected function hasColorSupport()
    {
        // @codeCoverageIgnoreStart
        if (DIRECTORY_SEPARATOR == '\\') {
            return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
        }

        return function_exists('posix_isatty') && @posix_isatty($this->stream->stream);
        // @codeCoverageIgnoreEnd
    }
262738
public static function isBinaryValue($value)
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($value)) {
            return false;
        }

        $pattern = self::$patterns['binaryValue'];

        return (bool)preg_match($pattern, $value);
    }
195047
public static function isColorsSupported($stream = STDOUT): bool
    {
        if ('Hyper' === getenv('TERM_PROGRAM')) {
            return true;
        }

        try {
            if (\DIRECTORY_SEPARATOR === '\\') {
                return (
                        function_exists('sapi_windows_vt100_support')
                        && @sapi_windows_vt100_support($stream)
                    ) || getenv('ANSICON') !== false
                    || getenv('ConEmuANSI') == 'ON'
                    || getenv('TERM') == 'xterm';
            }

            if (\function_exists('stream_isatty')) {
                return @stream_isatty($stream);
            }

            if (\function_exists('posix_isatty')) {
                return @posix_isatty($stream);
            }

            $stat = @fstat($stream);

            // Check if formatted mode is S_IFCHR
            return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
        } catch (\Throwable $e) {
            return false;
        }
    }
523892
public function setThreshold()
    {
        if (is_array($this->data['threshold']) === false) {
            $this->data['threshold'] = ['limit' => $this->data['threshold']];
        }
        else {
            if (count($this->data['threshold']) > 1) {
                $this->data['threshold'] = [
                    'limit' => $this->data['threshold'][1],
                    'offset' => $this->data['threshold'][0],
                ];
            }
            else {
                $this->data['threshold'] = [
                    'limit' => $this->data['threshold'][0]
                ];
            }
        }

        $this->builder->limit(implode(',', array_reverse($this->data['threshold'])));

        return null;
    }
734167
public static function IsEmpty($str, $trim = false) {
		return is_null($str) || static::STRING_EMPTY === ((!$trim) ? $str : trim($str, $trim));
	}
556844
static function setImageColorThreshold( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
                                            $thresholdList )
    {
        foreach ( array_keys( $thresholdList ) as $thresholdKey )
        {
            $thresholdList[$thresholdKey]['color'] = ImageColorAllocate( $imageObject, $thresholdItem['rgb'][0], $thresholdItem['rgb'][1], $thresholdItem['rgb'][2] );
        }
        $defaultColor = $thresholdList[count( $thresholdList ) - 1]['color'];

        $width = ImageSX( $imageObject );
        $height = ImageSY( $imageObject );
        for ( $y = 0; $y < $height; ++$y )
        {
            for ( $x = 0; $x < $width; ++$x )
            {
                $rgb = ImageColorAt( $imageObject, $x, $y );

                $r = ( $rgb >> 16 ) & 0xff;
                $g = ( $rgb >> 8 ) & 0x0ff;
                $b = ( $rgb ) & 0x0ff;

                $luminance = ( $r * 0.3 ) + ( $g * 0.59 ) + ( $b * 0.11 );

                $color = false;
                foreach ( $thresholdList as $thresholdItem )
                {
                    if ( $luminance <= $thresholdItem['threshold'] )
                    {
                        $color = $thresholdItem['color'];
                        break;
                    }
                }
                if ( $color === false )
                    $color = $defaultColor;

                ImageSetPixel( $imageObject, $x, $y, $color );
            }
        }
        return $imageObject;
    }
860275
public function setGlobalThreshold($threshold)
  {
    if (ThrottlerHelper::validateGlobalThreshold($threshold)
        && ThrottlerHelper::compareThresholds($this->getComponentThreshold(), $threshold)
        && !$this->isActive())
    {
      $this->globalThreshold = $threshold;
      return true;
    }
    return false;
  }
98947
public static function isZeroOrOne($digit)
    {
        if (strlen($digit) > 0) {
            $digit = intval($digit);
            return $digit === 0 || $digit === 1;
        }
        return false;
    }
392504
protected function validateBinIsExecutable($bin)
    {
        $result = false;

        if (is_file($bin) && is_executable($bin)) {
            $this->printTaskSuccess("<info>$bin</info> is executable");
            $result = true;
        } else {
            $this->printTaskError("$bin not executable");
        }

        return $result;
    }
552100
protected function isBinary()
    {
        $binary = false;

        if (($this->dcs & 200) === 0) {
            $binary = (($this->dcs & 4) > 0);
        } elseif (($this->dcs & 248) === 240) {
            $binary = (($this->dcs & 4) > 0);
        }

        return $binary;
    }
655698
public function isBright($color, $threshold=127.5): bool
    {
        $c = color($color);
        return is_bright($c, $threshold);
    }
1120792
private function validateParameter(string $parameter): bool
    {
        $properties = explode('=', $parameter);

        return 2 != count($properties) || strtolower($properties[0]) === static::BINARY_PARAMETER;
    }