Grego Posted February 11, 2008 Share Posted February 11, 2008 I've got the basics of PHP GD sorted but I have a problem. As part of my dynamic image, I want to load another image into it. So I want to insert an image with a given URL into the image at a given position. I also want to blend that image with a particular colour. Essentially, I want this function to exist: coolnewfunction($im,"images/image.png",$x,$y,$color) Where $im is the image I'm creating, $x and $y give the location to insert it at and $color is the colour to blend it with. Is it possible to load an image into a GD image and, if so, is it possible to blend that with a colour before I add it? And if yes, I'd obviously like to know how. Thanks in advance =) Quote Link to comment https://forums.phpfreaks.com/topic/90548-php-gd-inserting-images/ Share on other sites More sharing options...
schilly Posted February 11, 2008 Share Posted February 11, 2008 I'm pretty sure you can but my GD experience hasn't been too extensive other than creating thumbs. You probably want to create a new image resource and create another image resource from the source image. Then use one of the imagecopy (http://ca.php.net/manual/en/function.imagecopymerge.php) functions to overlay. I'm not sure about the blending part thought. It's probably a little tricky. Quote Link to comment https://forums.phpfreaks.com/topic/90548-php-gd-inserting-images/#findComment-464258 Share on other sites More sharing options...
Grego Posted February 11, 2008 Author Share Posted February 11, 2008 That's really useful, thanks =D Do you know how to merge transparent colours well? I have a bottom image which is full colour and one to put on top with transparent parts? It seems to fill it in white... Quote Link to comment https://forums.phpfreaks.com/topic/90548-php-gd-inserting-images/#findComment-464274 Share on other sites More sharing options...
schilly Posted February 11, 2008 Share Posted February 11, 2008 you might need to define white as a transparent colour for that image. http://ca3.php.net/manual/en/function.imagecolortransparent.php not positive though. Quote Link to comment https://forums.phpfreaks.com/topic/90548-php-gd-inserting-images/#findComment-464293 Share on other sites More sharing options...
Barand Posted February 11, 2008 Share Posted February 11, 2008 you could look at imagefilter() with a filter type of IMG_FILTER_COLORIZE and apply that prior to an imagecopymerge() Quote Link to comment https://forums.phpfreaks.com/topic/90548-php-gd-inserting-images/#findComment-464397 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.