Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to put text watermark on site images

Posted on 2011-09-11
7
384 Views
Last Modified: 2012-05-12
how to put text watermark on site images :

is there any class or something can do that ....

example :  (www.bokra.net) --> watermark

 2-20-2836-29.jpg
0
Comment
Question by:YUYU
  • 3
7 Comments
 

Expert Comment

by:PetrVitek
ID: 36521210
Are you talking about adding them dynamically ? ( i guess )

2 options i think:

1) if you have hosting that allows you to run shell, you can use imagemagick utility.
2) if not you probably have to use GD library and change the images from php directly

All images need to be linked thrugh php ( no direct access to the images ) or yet better redirect the request to watermarked image automatically with .htaccess
.htaccess can check if the watermaked image is prepared ( file exists )
if yes - redirect directly to image
if not - redirect to php script that will create the watermarked image.

the php script will create new image combining the watermark image with the original, and saving it so it needs to be done only once.

example of creating the image - http://www.sitepoint.com/watermark-images-php/

I suggest you don't do it everytime image is requested, but save it, as the image manipulation through GD is really memory expensive.

0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 36521673
The watermark in the image above is not really "text."  It is a stylized image of a text string.  Here is how you do it.
http://www.laprbass.com/RAY_image_watermark.php

This script uses the images here:
http://www.LAPRBass.com/RAY_add_watermark_source_image.png
http://www.LAPRBass.com/RAY_add_watermark_watermark_image.png

HTH, ~Ray
<?php // RAY_image_watermark.php
error_reporting(E_ALL);

// LOCATION OF THE IMAGES (COULD COME IN FROM $_GET URL STRING)
$original = 'http://www.LAPRBass.com/RAY_add_watermark_source_image.png';
$h2o_mark = 'http://www.LAPRBass.com/RAY_add_watermark_watermark_image.png';

// READ THE IMAGE AND THE WATERMARK FILE
// MAN PAGE http://php.net/manual/en/function.imagecreatefrompng.php
$im = ImageCreateFromPNG($original);
$wm = ImageCreateFromPNG($h2o_mark);

// ADD WATERMARK USING LOCAL FUNCTION
imagelogo($im, $wm, imagesx($im), imagesy($im), imagesx($wm), imagesy($wm));

// SHOW THE IMAGE
header('Content-type: image/png');
ImagePNG($im);

// A FUNCTION TO ADD THE LOGO WATERMARK
// SEE http://php.net/manual/en/function.imagealphablending.php#77085
function imagelogo (&$dst_image, $src_image, $dst_w, $dst_h, $src_w, $src_h)
{
    ImageAlphaBlending($dst_image,TRUE);
    ImageAlphaBlending($src_image,TRUE);
    ImageCopy($dst_image, $src_image, ($dst_w-$src_w), ($dst_h-$src_h), 0, 0, $src_w, $src_h);
}

Open in new window

0
 

Author Comment

by:YUYU
ID: 36551684
I've requested that this question be deleted for the following reason:

no benefit solution
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 36551685
I object to deleting this question.  This is a very well understood design pattern, used daily by thousands of sites around the world.  I posted a tested and working code example showing exactly how it is done.  I posted the test data, the complete code, and a link to the script so you can see it in action.  It's all there and it works.  If you have some kind of misunderstanding of the solution I posted, please give us your comments or at least try to work with us instead of just deleting the question.  Thanks, ~Ray
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 36552463
Recommend accept http:#36521673 -- that is how it is done in the real world by the professionals.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question