Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extract PNG Images From Favicon ICO Images in PHP Using ImageMagick
<?php
// Extract favicon images from file path.
$faviconFile = __DIR__ . '/bbc.ico'
file_put_contents($faviconFile, file_get_contents('https://www.bbc.co.uk/favicon.ico'));
$imagick = new Imagick();
$imagick->readImage($faviconFile);
$imagick->writeImages(__DIR__ . '/bbc-extracted.png', false);
// Extract favicon images from string.
$imagick = new Imagick();
$imagick->setFormat('ICO');
$imagick->readImageBlob(file_get_contents('https://www.bbc.co.uk/favicon.ico'));
$imagick->writeImages(__DIR__ . '/bbc-extracted.png', false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.