You are here: Re: Transparent overlay watermark - on the fly - resolved? « PHP Programming Language « IT news, forums, messages
Re: Transparent overlay watermark - on the fly - resolved?

Posted by Chuck Anderson on 03/22/07 21:25

Chuck Anderson wrote:
> j.l.l@web.de wrote:
>
>> Rami Elomaa schrieb:
>>
>>
>>> Chuck Anderson kirjoitti:
>>>
>>>
>>>> Is it possible to overlay a transparent watermark on an image -
>>>> dynamically?
>>>>
>>>>
>>
>>
>>> Yeah, I've done this. What you do is you open image handles to both
>>> files, the original image (imagecreatefromjpg) and the png watermark
>>> (imagecreatefrompng), then combine them with either imagecopy,
>>> imagecopyresampled or some other imagecopy* function that works best for
>>> you. Just go ahead and try them.
>>>
>>>
>> I've done one transparent overlay of two pictures, too, but found it a
>> bit tricky to do.
>>
>> You have to be careful with using imagecopymerge. As i remember there is
>> a parameter to allow transparency to be used

>> .....
>>
>
> Okay, thanks for all the help. I see now that the imagecopy....
> functions do what I need. The only one that lets you adjust the
> transparency of the overlaying image, though, is imagecopymerge.
>
> One big problem is that I am having no luck with using a png for the
> overlay. There is a background color, not transparency.
>
> I've added more to the example page.
> <http://www.cycletourist.com/temp/photo.php>
>
> The top image is one I created in Paint Shop Pro by pasting the
> transparent png over a photo image multiple times. I really like the
> look of the transparency there.
>
> The two gray boxes under the photo contain the png and gif images I am
> using for the watermark. The background behind the watermark images is
> set with CSS. The png version is 24 bit with alpha channel
> transparency. The gif image had to be blended with some color so I
> chose a light medium gray (which you can see on top of the background).
> If you click on either of those you can see the respective Php generated
> results.
>
> .....

> So, ... questions ....
> 1. Can I get results more like the image I created in Paint Shop Pro?
> 2. Why is the png not transparent when I use imagecopymerge (and will it
> look better if I get it working)?

> [previous script deleted]
>

Okay, I finally found the answer(s) I needed to make this work.

First. For the watermark, you must use a 24 bit png (not 8 bit) - and
the best results, by far, are with alpha transparency. (A transparent
gif watermark works, but a transparent png produces much better quality.)

Second - Do *not* use imagecopymerge (with a transparent png
watermark). It "destroys" the transparency in the png. I chose
imagecopyresampled because I want to re-size the watermark to fit the
image, and this produces better results than imagecopyresized.

My new results are here - in the old same place:
http://www.cycletourist.com/temp/photo.php

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.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

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