Jump to content

creating transparent images (that aren't speckled)


michaellunsford

Recommended Posts

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 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 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 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 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.

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.