pleek Posted June 2, 2009 Share Posted June 2, 2009 Ok, so im learning GC and alls going well but im stuck. The second image that is supposed to merge with $background isn't showing up. <?php header('Content-type: image/png'); $String = $_GET['text']; $UserRank = imagecreatefrompng('elitemember.png'); $UserAvatar = imagecreatefromgif('avatar.gif'); $Background = imagecreatefrompng('Background.png'); $TextColor = imagecolorallocate($Background, 225, 225, 225); $Font = imageloadfont('Kozuka Gothic Pro B.gdf'); imagestring($Background, $Font, 90, 15, $String, $TextColor); imagecopymerge($Background, $UserRank, 110, 55, 0, 0, 128, 28, 100); imagecopymerge($Background, $UserAvatar, 20, 20, 0, 0, 160, 160, 100); imagepng($Background); imagedestroy($Background); imagedestroy($UserRank); imagedestroy($UserAvatar); ?> The image $UserAvatar is not showing up but $UserRank is. Also how can i stop the transparent parts in $background from turning black? Here is the result Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/ Share on other sites More sharing options...
pleek Posted June 2, 2009 Author Share Posted June 2, 2009 anybody? lol bump! Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/#findComment-847794 Share on other sites More sharing options...
Garethp Posted June 2, 2009 Share Posted June 2, 2009 A) It's GD, not GC B) How big is UserRank? Maybe it's covering UserAvatar? And I don't see where you set the transparency for $background Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/#findComment-847801 Share on other sites More sharing options...
pleek Posted June 2, 2009 Author Share Posted June 2, 2009 if you clicked the "here is the result" link you can see how big userrank is. It 128 * 28. And im not sure how to set the transparency for $background. How do i do that? And yes i know its GD not GD. But i didn't notice my error till after i posted it and it won't let me edit it. Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/#findComment-847827 Share on other sites More sharing options...
Garethp Posted June 2, 2009 Share Posted June 2, 2009 Learn to google http://www.bitrepository.com/image-transparency-with-gd.html Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/#findComment-847831 Share on other sites More sharing options...
pleek Posted June 2, 2009 Author Share Posted June 2, 2009 alright, that helped me out. I had seen that but i overlooked part of it. Now, can anybody tell me why i can't get gifs to load with createimagefromgif? pngs work fine. Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/#findComment-848153 Share on other sites More sharing options...
pleek Posted June 3, 2009 Author Share Posted June 3, 2009 bump* i can put as many pngs as i want using imagecopymerge and imagecopy. But beyond the background gif i can't get any more gifs to work. And now that i got the transparencies working the imagestring won't show up. heres the new code. <?php header('Content-type: image/png'); // Set a White & Transparent Background Color $new_image = ImageCreateTruecolor(345, 130); $bg = ImageColorAllocateAlpha($new_image, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5) ImageFill($new_image, 0, 0 , $bg); $String = $_GET['text']; $UserRank = imagecreatefrompng('elitemember.png'); $UserAvatar = imagecreatefrompng('avatar.png'); $Background = imagecreatefromgif('Background.gif'); $TextColor = imagecolorallocate($Background, 225, 225, 225); $Font = imageloadfont('Kozuka Gothic Pro B.gdf'); imagecopymerge($new_image, $Background, 0, 0, 0, 0, 345, 130, 50); imagecopymerge($new_image, $UserRank, 110, 55, 0, 0, 128, 28, 100); imagecopy($new_image, $UserAvatar, 0, 0, 0, 0, 128, 128); imagestring($new_image, $Font, 90, 15, $String, $TextColor); imagepng($new_image); imagedestroy($new_image); imagedestroy($Background); imagedestroy($UserAvatar); imagedestroy($UserRank); ?> view it here Link to comment https://forums.phpfreaks.com/topic/160572-combining-images-with-php-gc/#findComment-848276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.