homepage Welcome to WebmasterWorld Guest from 184.72.69.79
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
image transparency not working with rough edges
remove rough edges and use alpha
phparion




msg:3622693
 2:33 pm on Apr 9, 2008 (gmt 0)

Hi

I am trying to write a code that can pick a watermark image, gif/png/jpeg, and put it on a destination image,gif/png/jpeg, with transparancy.

For the watermark I created an image in photoshop with transparent background. Now the script works fine but it shows rough white edges around the watermark image. Also is it possible to alpha the watermark image so that we can see through it ? i.e the destination image is visible through it?

here is my code

$image = imagecreatefromstring(file_get_contents("jack-tank.jpg"));

$w = imagesx($image);
$h = imagesy($image);

// Load the watermark image
$watermark = imagecreatefromgif('dil.gif');
$ww = imagesx($watermark);
$wh = imagesy($watermark);

// Merge watermark upon the original image
imagecopy($image, $watermark, $w-$ww, $h-$wh, 0, 0, $ww, $wh);

// Send the image
header('Content-type: image/jpeg');
imagejpeg($image);
exit();

if you know any class or code snippet please share.

thank you

 

Little_G




msg:3622715
 3:16 pm on Apr 9, 2008 (gmt 0)

Hi,

Have you tried imagecopymerge [php.net] instead of imagecopy?
You might want to take a look at imagealphablending [php.net] as well.

Andrew

[edited by: Little_G at 3:18 pm (utc) on April 9, 2008]

phparion




msg:3622761
 4:10 pm on Apr 9, 2008 (gmt 0)

That worked very well G, however I am still failed to remove the ROUGHT EDGES of my watermark image...

1) i made a watermark image in photoshop with transparent background.

2) when I display it on the page, it works with transparency with imagecopymerge() however the white-rough-edges are still there.

How can I remove the white-rough/crude edges of the watermark. it is not seamless.

thank you

Little_G




msg:3622778
 4:24 pm on Apr 9, 2008 (gmt 0)

Hi,

Are you saying the rough edges are present in the watermark image before you open it in PHP?

Andrew

phparion




msg:3622841
 5:41 pm on Apr 9, 2008 (gmt 0)

yeah, when it appears on the image, it shows rough white edges around the image border.

whoisgregg




msg:3623586
 1:56 pm on Apr 10, 2008 (gmt 0)

You should change your settings of how you export it from Photoshop. Export to PNG and make sure you have "alpha transparency" enabled.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved