You are here: Re: [PHP] watermark png on jpg « PHP « IT news, forums, messages
Re: [PHP] watermark png on jpg

Posted by tedd on 01/03/06 17:38

>I have png image with transparent background, and 1 jpg file.
>I use imageCopyMerge to paste the png image on the jpg image.
>
>the result image contain no transparent background mean the png file
>have white background when its suppose to be transparent
>
>what is the simple and best way to make this work.
>
>tanks in advance. :)

Libit:

I was working on the same thing. The following is a solution -- but,
simple and best are relative.

This was taken from "PHP Graphics Handbook" by Kent et al.

<?
$original=imagecreatefromjpeg("apollo.jpg");
$watermark=imagecreatefrompng("xssportstransparent.png");

$osx=imagesx($original);
$osy=imagesy($original);
$wsx=imagesx($watermark);
$wsy=imagesy($watermark);

imagecopy($original, $watermark, ($osx-$wsx)/2, ($osy-$wsy)/2, 0, 0,
$wsx, $wsy);

imagepng($original, "apollo_trans.png");

?>
<html>
<body>
<table>
<tr><td align=center>Orignal Image</td><td
align=center>Watermark</td><td align=center>Orignal Image with
Watermark</td></tr>
<tr><td><img src="apollo.jpg"></td><td><img
src="xssportstransparent.png"></td><td><img
src="apollo_trans.png"></td></tr>
</table>
</body>
</html>

Demo at:

http://xn--ovg.com/watermark

HTH's

tedd

--
--------------------------------------------------------------------------------
http://sperling.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация