Get displayed icon

@param   int  $maxSize
@return  string|null
421700
public function getDisplayedIcon( $maxSize = self::DEFAULT_ICON_SIZE )
    {
        if ( empty( $this->displayIcon ) )
        {
            return null;
        }

        $foundSize = 0;
        $foundIcon = null;

        foreach ( $this->displayIcon as $size => $icon )
        {
            if ( $size >= $foundSize && $size <= $maxSize )
            {
                $foundSize = $size;
                $foundIcon = $icon;
            }
        }

        if ( ! empty( $foundIcon ) )
        {
            $replace = array(
                '%version%'     => '0',
                '%reference%'   => '-',
            );

            if ( ! empty( $this->availableVersion ) )
            {
                $replace['%version%'] = $this->availableVersion;
            }
            else if ( ! empty( $this->installedVersion ) )
            {
                $replace['%version%'] = $this->installedVersion;
            }

            if ( ! empty( $this->availableReference ) )
            {
                $replace['%reference%'] = $this->availableReference;
            }
            else if ( ! empty( $this->installedReference ) )
            {
                $replace['%reference%'] = $this->installedReference;
            }

            $foundIcon = strtr( $foundIcon, $replace );
        }

        return $foundIcon;
    }
1031734
public function getIcon($default = null)
    {
        if ($this->icon !== null && $this->icon !== '') {
            return '<i class="' . $this->icon . '"></i>';
        }
        if ($default === null) {
            return $default;
        }

        return '<i class="' . $default . '"></i>';
    }
1034679
public function getIcon()
    {
        if (!$this->icon) {
            return "";
        }
        return Html::get()->image($this->icon, $this->translate($this->label));
    }
370093
public static function getIconsFolder(string $extensionKey, string $prefix = 'EXT:'): string {
    return self::iconsFolder($extensionKey, $prefix);
  }
1248153
public function getImageSizeInBox(array $imageSize, array $boxSize)
    {
        list($imageWidth, $imageHeight) = $imageSize;
        list($boxWidth, $boxHeight) = $boxSize;

        if (($imageWidth <= $boxWidth) && ($imageHeight <= $boxHeight)) {
            return $imageSize;
        }

        $resizeRatio = min($boxWidth / $imageWidth, $boxHeight / $imageHeight);

        $imageWidth = ceil($imageWidth * $resizeRatio);

        if ($imageWidth > $boxWidth) {
            $imageWidth = $boxWidth;
        }

        $imageHeight = ceil($imageHeight * $resizeRatio);

        if ($imageHeight > $boxHeight) {
            $imageHeight = $boxHeight;
        }

        return array($imageWidth, $imageHeight);
    }
434244
public function getIconFilename(\ElggEntity $entity, $size = '') {

		$mimetype = $entity->icon_mimetype ? : $entity->mimetype;
		switch ($mimetype) {
			default :
				$ext = 'jpg';
				break;
			case 'image/png' :
				$ext = 'png';
				break;
			case 'image/gif' :
				$ext = 'gif';
				break;
		}

		$sizes = $this->getSizes($entity);
		if (isset($sizes[$size]['metadata_name'])) {
			$md_name = $sizes[$size]['metadata_name'];
			$filename = $entity->$md_name;
		}
		if (!$filename) {
			$filename = "{$entity->guid}{$size}.{$ext}";
		}
		return elgg_trigger_plugin_hook('entity:icon:directory', $entity->getType(), array(
			'entity' => $entity,
			'size' => $size,
				), $filename);
	}
24749
public function resizeTable(int $maxSize = null) {
        if ($maxSize !== null) {
            $this->maxSize = $maxSize;
        }

        while ($this->size > $this->maxSize) {
            list($name, $value) = \array_pop($this->headers);
            $this->size -= 32 + \strlen($name) + \strlen($value);
        }
    }
1168756
public function getIconUrl()
    {
        if (($sIcon = $this->oxcategories__oxicon->value)) {
            $oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
            $sSize = $oConfig->getConfigParam('sCatIconsize');
            if (!isset($sSize)) {
                $sSize = $oConfig->getConfigParam('sIconsize');
            }

            return \OxidEsales\Eshop\Core\Registry::getPictureHandler()->getPicUrl("category/icon/", $sIcon, $sSize);
        }
    }
1296886
public static function getMaxUploadSize($max_size = 0): int
    {
        $post_max_size = FormatHelper::convertBytes(ini_get('post_max_size'));
        $upload_max_fileSize = FormatHelper::convertBytes(ini_get('upload_max_filesize'));

        if ($max_size > 0) {
            $result = min($post_max_size, $upload_max_fileSize, $max_size);
        } else {
            $result = min($post_max_size, $upload_max_fileSize);
        }

        return $result;
    }
625432
private function getIconPath(FileStorage $entity, string $version) : string
    {
        $imgSizes = (array)Configure::read(sprintf('FileStorage.imageSizes.%s', $entity->get('model')));

        // no image sizes, return default
        if (empty($imgSizes)) {
            return Utility::getFileTypeIcon($entity->get('extension'));
        }

        // sort by size, biggest first and get current version position in the array
        $position = array_search($version, array_keys(Hash::sort($imgSizes, 'width')), true);

        // no position, return default
        if (false === $position) {
            return Utility::getFileTypeIcon($entity->get('extension'));
        }

        $iconSizes = [512, 48, 32, 16];
        // traversing recursively through the icon sizes until it finds the closest one by key position
        $funcGetIconSize = function (int $pos) use ($iconSizes, &$funcGetIconSize) {
            if (! array_key_exists($pos, $iconSizes)) {
                return $funcGetIconSize($pos - 1);
            }

            return $iconSizes[$pos];
        };

        $result = Utility::getFileTypeIcon($entity->get('extension'), sprintf('%dpx', $funcGetIconSize($position)));

        $result = $this->getUrlHelper()->image($result);

        return $result;
    }
127901
public function getIconByMimeType($mimeType)
    {
        return array_key_exists($mimeType, $this->icons) ? $this->icons[$mimeType] : null;
    }
972175
private Icon getIcon( Severity severity ) {
        if( severity == Severity.ERROR ) {
            return getErrorIcon();
        }
        if( severity == Severity.WARNING ) {
            return getWarningIcon();
        }
        return getInfoIcon();
    }
1063585
public function extract($maxPaletteSize = 1)
	    {
	        $w = imagesx($this->imageResource);
	        $h = imagesy($this->imageResource);

	        $colors = [];

	        for ($x = 0; $x < $w; $x++) {
	            for ($y = 0; $y < $h; $y++) {
	                $rgba = imagecolorsforindex($this->imageResource, imagecolorat($this->imageResource, $x, $y));
	                
	                if ($rgba['alpha'] == 127) {
	                    continue;
	                }

	                $color = hexdec(sprintf('%02X%02X%02X', $rgba['red'], $rgba['green'], $rgba['blue']));

	                if (array_key_exists($color, $colors)) {
	                    $colors[$color]++;
	                } else {
	                    $colors[$color] = 1;
	                }
	            }
	        }

	        $totalColorCount = $finalColorCount = count($colors);
	        $minCountAllowed = $w * $h * $this->minColorRatio;

	        foreach ($colors as $color => &$data) {
	            if ($data < $minCountAllowed) {
	                unset($colors[$color]);
	                $finalColorCount--;
	            } else {
	                $data = $this->getColorScore($color, $data, $totalColorCount);
	            }
	        }

	        arsort($colors, SORT_NUMERIC);

	        $paletteSize = min($maxPaletteSize, $finalColorCount);

	        if ($finalColorCount > $maxPaletteSize) {
	            $minDeltaE = 100 / ($paletteSize + 1);
	            $LabCache = [];

	            $i = 0;
	            $mergeCount = 0;

	            while ($i++ < $paletteSize) {
	                if ($paletteSize >= count($colors)) {
	                    break;
	                }

	                $j = 0;
	                reset($colors);

	                while (++$j < $i) {
	                    next($colors);
	                }

	                $refColor = key($colors);

	                if (!array_key_exists($refColor, $LabCache)) {
	                    $LabCache[$refColor] = $this->getLabFromColor($refColor);
	                }

	                if ($mergeCount) {
	                    $offset = max($i, $paletteSize - $mergeCount - 1);
	                    
	                    while ($j++ < $offset) {
	                        next($colors);
	                    }

	                    $mergeCount = 0;
	                }

	                while ($j++ <= $paletteSize) {
	                    next($colors);
	                    $cmpColor = key($colors);

	                    if (!array_key_exists($cmpColor, $LabCache)) {
	                        $LabCache[$cmpColor] = $this->getLabFromColor($cmpColor);
	                    }

	                    if ($this->ciede2000DeltaE($LabCache[$refColor], $LabCache[$cmpColor]) <= $minDeltaE) {
	                        $j--;
	                        $mergeCount++;
	                        prev($colors);
	                        unset($colors[$cmpColor]);
	                        if ($i > 1) {
	                            $i = 0;
	                        }
	                    }
	                }
	            }
	        }

	        return array_map(
	            [__CLASS__, 'toHex'],
	            array_keys(array_slice($colors, 0, $paletteSize, true))
	        );
	    }
789547
public function resolve(MediaType $mediaType, $requestedSize = null)
    {
        $icons = $mediaType->getIcons();
        if (!count($icons)) {
            return null;
        }
        ksort($icons);

        if (isset($icons[$requestedSize])) {
            $icon = $icons[$requestedSize];
        } else {
            $icon = null;
            foreach ($icons as $size => $dummyIcon) {
                if ($size > $requestedSize) {
                    $icon = $dummyIcon;
                    break;
                }
            }
            if (!$icon) {
                $icon = end($icons);
                //return null;
            }
        }

        return $this->locator->locate($icon, null, true);
    }
913264
function getMatchingIcons(iconsWithScores, maxScore) {
  return iconsWithScores
    .filter((item) => item.score === maxScore)
    .map((item) => Object.assign({}, item, { ext: path.extname(item.url) }));
}
159872
public function getIconType(?string $extension): string
    {
        if ($extension !== null && $extension !== '') {
            foreach (self::TYPE_TO_REGEX as $type => $regex) {
                if ($regex === null) {
                    continue;
                }
                if (($regex === $extension && preg_match('/[a-z0-9]+/', $extension))
                    || preg_match("/$regex/", $extension)
                ) {
                    return $type;
                }
            }
        }

        return self::ICON_DEFAULT;
    }
661475
public function getIcon($default = null, $show = true)
    {
        if ($this->icon !== null && $this->icon !== '' && $show == true ) {
            return '<i class="' . $this->icon . '"></i>';
        }
        if ($default === null && $show == true) {
            return $default;
        } else {
            return $this->icon;
        }
        return '<i class="' . $default . '"></i>';
    }