Search by

konradmichalik / php-ico-file-loader

konradmichalik

Powerful PHP package for reading and converting .ico files, perfect for handling website favicons

Package info

github.com/konradmichalik/php-ico-file-loader

pkg:composer/konradmichalik/php-ico-file-loader

Statistics

Installs: 36 982

Dependents: 1

Suggesters: 0

Stars: 2

Open Issues: 0


README

icon

Php Ico File Loader

Coverage CGL Tests Supported PHP Versions

This package enables loading and converting .ico files within PHP applications. It requires no dependencies except for gd for image rendering.

🔥 Installation

Packagist Packagist Downloads

composer require konradmichalik/php-ico-file-loader

⚡ Usage

$loader = new KonradMichalik\PhpIcoFileLoader\IcoFileService;
$im = $loader->extractIcon('/path/to/icon.ico', 32, 32);

imagepng($im, '/path/to/output.png');

Pass untrusted bytes, such as a downloaded favicon, to fromString(). from() and extractIcon() fall back to treating unrecognised data as a local file path.

PNG data is rejected above 1024 x 1024 pixels, for standalone PNGs and for PNGs inside an ICO. To raise the limit, pass it to the parser and to the renderer:

use KonradMichalik\PhpIcoFileLoader\IcoFileService;
use KonradMichalik\PhpIcoFileLoader\Parser\IcoParser;
use KonradMichalik\PhpIcoFileLoader\Renderer\GdRenderer;

$loader = new IcoFileService(
    new GdRenderer(maxPngPixels: 2048 * 2048),
    new IcoParser(maxPngPixels: 2048 * 2048),
);

💛 Acknowledgements

This project is a fork and further development of lordelph/icofileloader.

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under MIT.