michaellunsford Posted January 9, 2007 Share Posted January 9, 2007 I'm resizing and copying a transparent gif to a transparent gdlib image. After copying, the transparency gets speckled. Also, it may be noteworthy that imagecopy() and imagecopyresized() don't bring transparency with them. I'm guessing the original image has one transparent color and I have specified a different transparent color in the new image? If I use imagecolortransparent() to determine what color is transparent, it only returns the number "31" -- whatever that means.thoughts?[img]http://www.atchafalayablend.com/gallery/1_225.jpg[/img]Here's the code[code]<?php $im=imagecreatefromstring(file_get_contents("../images/someimage.gif")); $newim=imagecreatetruecolor($width,((imagesy($im)/imagesx($im))*$width)); if(imagecolortransparent($im)!=="-1") { $trans_color = imagecolorallocate($newim, 255, 255, 255); $color = imagecolorallocate($newim, 0, 0, 0); imagecolortransparent($newim, $trans_color); } imagefill($newim,0,0,imagecolorallocate($newim, 255,255,255)); imagecopyresampled($newim,$im,0,0,0,0,$width,((imagesy($im)/imagesx($im))*$width),imagesx($im),imagesy($im)); imagedestroy($im); imagegif($newim);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/ Share on other sites More sharing options...
taith Posted January 9, 2007 Share Posted January 9, 2007 the reason why that happens... is because the picture background itself isnt exactly white, open it in gimp, color find, you'll find they are different colours... most likely. Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-156769 Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 You might have to run it a few times on a few shades, as the compression of the image probably caused it to be not solid white, but shades of white/off white.Good luck Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-156775 Share on other sites More sharing options...
michaellunsford Posted January 9, 2007 Author Share Posted January 9, 2007 [quote author=jesirose link=topic=121672.msg500747#msg500747 date=1168370100]You might have to run it a few times on a few shades[/quote]I'm not quite sure what you mean. GIF only allows a single color to be transparent (I believe). All testing with multiple colors just gives me a flat image (no transparency at all). In fact, if I choose a color other than white, it's been going flat. Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-156861 Share on other sites More sharing options...
bubblybabs Posted January 10, 2007 Share Posted January 10, 2007 [quote author=michaellunsford link=topic=121672.msg500835#msg500835 date=1168382052][quote author=jesirose link=topic=121672.msg500747#msg500747 date=1168370100]You might have to run it a few times on a few shades[/quote]I'm not quite sure what you mean. GIF only allows a single color to be transparent (I believe). All testing with multiple colors just gives me a flat image (no transparency at all). In fact, if I choose a color other than white, it's been going flat.[/quote]No, at least with Photoshop you can choose multiple colors... If you want I can make it transparent for you... Send it to me at [my forum nickname]@[mywebsite.com]and my website is fractalfairy.com Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-157115 Share on other sites More sharing options...
Jessica Posted January 10, 2007 Share Posted January 10, 2007 Can you show the original image please? Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-157116 Share on other sites More sharing options...
DarkendSoul Posted January 10, 2007 Share Posted January 10, 2007 Um, you do realize that even if you do get this to work right inside the first black line will be transparent too, and there will be no fading black into the transparency it'll just have a white 'halo'. Its best to do this in photoshop. Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-157124 Share on other sites More sharing options...
michaellunsford Posted January 10, 2007 Author Share Posted January 10, 2007 [quote author=jesirose link=topic=121672.msg501095#msg501095 date=1168407710]Can you show the original image please?[/quote]sorry[img]http://www.atchafalayablend.com/images/pack_o_peppers.gif[/img][quote author=DarkendSoul link=topic=121672.msg501103#msg501103 date=1168408673]Its best to do this in photoshop.[/quote]Yeah, I know. The problem is these are client uploaded images. There are only a few now, but someday soon they'll have dozens or hundreds. Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-157326 Share on other sites More sharing options...
bubblybabs Posted January 10, 2007 Share Posted January 10, 2007 How's this? Somewhat difficult to work with since it's already been altered...Babs[img]http://www.fractalfairy.com/pack-o-peppers.gif[/img] Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-157358 Share on other sites More sharing options...
HuggieBear Posted January 10, 2007 Share Posted January 10, 2007 [quote author=bubblybabs link=topic=121672.msg501338#msg501338 date=1168440036]How's this? Somewhat difficult to work with since it's already been altered...[img]http://www.fractalfairy.com/pack-o-peppers.gif[/img][/quote]BB, I think you're really missing the point here... What Michael's probably saying is that his clients will be uploading many images from now and in the future, and if GD could do the work for him it would be a whole lot better than having to do it manually every time.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/33491-creating-transparent-images-that-arent-speckled/#findComment-157363 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.