Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to get the image resource for use with GD #12

Open
rob-lindman opened this issue Nov 3, 2018 · 1 comment
Open

ability to get the image resource for use with GD #12

rob-lindman opened this issue Nov 3, 2018 · 1 comment

Comments

@rob-lindman
Copy link

this looks like a nice, lightweight ICO loader. the problem I was hoping to solve is to be able to load a favicon from the web and put it into a GD image resource and then perform some filters or other operations on it. it looks like this ability is missing and only saving to a file is available. perhaps someone familiar with the code can add a method to expose this.

@KEINOS
Copy link

KEINOS commented Nov 5, 2019

I agree.

Here's my work around, so far. Hope it might help for somebody.

<?php
require_once('php_ico.php');

// Create 16x16 px white image with 127 transparency as a sample
$res_image = imagecreatetruecolor(16, 16);
imagealphablending($res_image, false);
$color_bg = imagecolorallocatealpha($res_image,255,255,255,127);
imagefilledrectangle($res_image,0,0,16,16,$color_bg);
imagefill($res_image, 0, 0, $color_bg);
imagealphablending($res_image,true);

// Convert image to ICO format and get the result
$ico_lib = new PHP_ICO();
$ico_lib->_add_image_data($res_image);
$bin_ico = $ico_lib->_get_ico_data();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants