Created
March 4, 2020 18:46
-
-
Save ziadoz/a4a168ac83d194ce827c0e328ceebb7e to your computer and use it in GitHub Desktop.
Extract PNG Images From Favicon ICO Images in PHP Using ImageMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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