bjoern Posted January 31, 2008 Share Posted January 31, 2008 Hi everyone I got a problem I just can't seem to figure out :-\ I made this script for generating image reflection automatically. It all seems to work fine, except for one thing. I want the background of the png I am outputting to be transparent. Found a few ways to do that and it is transparent as of now. However, when I copy-merge from from the original image to the new image, the semi-transparency of the pixels does not blend in with the transparent background, but rather the original color. To see what I mean, here is the part of the code which is not work. // Create canvas for the output image $image = @imagecreatetruecolor($width, $height + $size + $offset); // Alpha and color properties required for transparent background imagesavealpha($image, true); $background-color = imagecolorallocatealpha($image, 255, 255, 255, 127); imagefill($image, 0, 0, $background-color); // Copy the original image to the canvas imagecopymerge($image, $imageinput, 0, 0, 0, 0, $width, $height, 100); // Flip the image vertical $opacity = $transparency / $size; for ($y = 0; $y < $size; $y++) { $x = $x + $opacity; imagecopymerge($image, $imageinput, 0, $height + $offset + $y, 0, $height - $y - 1, $width, 1, $transparency - $x); } imagepng($image); The for-loop copies from the input image to the new image i created and is transparent the way it should be, but it somehow ignores that the background of $image is set to opacity: 127.. Here is a screenshot, so you can see what I mean: Where the bug is showing: How it should look like, regardless of background color: So to summarize, I want the bottom part (the reflection) to be properly transparent and blend into whatever is in the background. As often the case, I fully understand the problem, but I do not have the solution Hope someone can help or perhaps provide an alternative solution. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/88735-problems-with-transparent-truecolor-png/ Share on other sites More sharing options...
haku Posted January 31, 2008 Share Posted January 31, 2008 What browser are you looking at it in? Early IE browsers have issues with png images just like you described. There are javascript fixes out there for that. Not really a PHP issue though. Quote Link to comment https://forums.phpfreaks.com/topic/88735-problems-with-transparent-truecolor-png/#findComment-454467 Share on other sites More sharing options...
bjoern Posted January 31, 2008 Author Share Posted January 31, 2008 I'm using firefox, so I know thats not the problem Quote Link to comment https://forums.phpfreaks.com/topic/88735-problems-with-transparent-truecolor-png/#findComment-454468 Share on other sites More sharing options...
bjoern Posted January 31, 2008 Author Share Posted January 31, 2008 As I said, the problem lies within the image itself.. If I drag it into photoshop, it still does not show up as I wanted (semi-transparent pixels) Quote Link to comment https://forums.phpfreaks.com/topic/88735-problems-with-transparent-truecolor-png/#findComment-454471 Share on other sites More sharing options...
bjoern Posted January 31, 2008 Author Share Posted January 31, 2008 *Bumb* Quote Link to comment https://forums.phpfreaks.com/topic/88735-problems-with-transparent-truecolor-png/#findComment-454646 Share on other sites More sharing options...
bjoern Posted February 8, 2008 Author Share Posted February 8, 2008 *bumb again* Quote Link to comment https://forums.phpfreaks.com/topic/88735-problems-with-transparent-truecolor-png/#findComment-461917 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.