public function extractIcon($dataOrFile, $w, $h, array $opts = null)
    {
        $icon = $this->from($dataOrFile);
        $image = $icon->findBestForSize($w, $h);
        if (!$image) {
            //nothing at our required size, so we'll find the highest quality icon
            $image = $icon->findBest();
        }
        if (!$image) {
            throw new \DomainException('Icon does not contain any images.');
        }
        return $this->renderImage($image, $w, $h, $opts);
    }
public function extractIcon($dataOrFile, $w, $h, array $opts = null)
    {
        $icon = $this->from($dataOrFile);
        $image = $icon->findBestForSize($w, $h);
        if (!$image) {
            //nothing at our required size, so we'll find the highest quality icon
            $image = $icon->findBest();
        }
        if (!$image) {
            throw new \DomainException('Icon does not contain any images.');
        }
        return $this->renderImage($image, $w, $h, $opts);
    }
public function extractIcon ( $ dataOrFile , $ w , $ h , array $ opts = null ) { $ icon = $ this -> from ( $ dataOrFile ) ; $ image = $ icon -> findBestForSize ( $ w , $ h ) ; if ( ! $ image ) { //nothing at our required size, so we'll find the highest quality icon $ image = $ icon -> findBest ( ) ; } if ( ! $ image ) { throw new \ DomainException ( 'Icon does not contain any images.' ) ; } return $ this -> renderImage ( $ image , $ w , $ h , $ opts ) ; }
This is a useful one-stop function for obtaining the best possible icon of a particular size from an .ico file

As icons are often hand-crafted to look good at particular sizes, this will try to use the best quality image
in the icon at the required size. If it can't be found, then it will resize the largest icon it can find.

This will either return a valid image, or will throw an \InvalidArgumentException in the event of the file
being unreadable.

@param string $dataOrFile Either a filename to a .ico file, or binary data from an .ico file in a string
@param integer $w Desired width. The class tries to locate the best quality image at this size, but
if not found, the largest available icon will be used and resized to fit.
@param integer $h Desired height - as icons are usually square, this should be same as $w.
@param array $opts Array of renderer options. The built in renderer supports an optional 'background'
elemen in this array. Normally, the result will use alpha transparency, but you can
pass a hex colour to choose the colour of the transparent area instead, e.g.
['background=>'#ffffff'] for a white background.
@return mixed              The built in renderer will return a gd image resource, which you could save with
the gd function imagepng(), for example. If you swap in an alternative renderer,
the result is whatever that renderer returns.
@throws \DomainException if icon does not contain any images.
@throws \InvalidArgumentException if file is not found or is invalid.
This is a useful one - stop function for obtaining the best possible icon of a particular size from an . ico file