Watermark script

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
phpbaby

Fri Apr 07, 2006 12:31 am

Hi there,

Anyone know the script to water mark a image in php?

Thanks in advance

sanketce
New php-forum User
New php-forum User
Posts: 90
Joined: Fri Dec 02, 2005 3:23 am

Fri Apr 07, 2006 12:59 am

Can you explain in more detail :)

phpbaby

Fri Apr 07, 2006 8:32 am

Hi,

When i add a picture to my server through the form , then a watermark for the uploaded picture is to be added below the picture. The watermark to be added nearly at the bottom of the picture automatically.

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Fri Apr 07, 2006 8:57 am

Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
Mukseh
New php-forum User
New php-forum User
Posts: 156
Joined: Wed Mar 22, 2006 2:22 am
Location: Ahmedabad, Gujarat, India
Contact:

Sun Apr 16, 2006 7:18 pm

Code: Select all

class water_mark {

    public static function apply($watermark, $img) {

        header('content-type: image/gif');

        $watermark = imagecreatefromgif($watermark);
        $watermark_width = imagesx($watermark);
        $watermark_height = imagesy($watermark);
        $image = imagecreatetruecolor($watermark_width, $watermark_height);
        $image = imagecreatefromgif($img);
        $size = getimagesize($img);
        $dest_x = $size[0] - $watermark_width -5;
        $dest_y = $size[1] - $watermark_height -5;
        imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
        imagejpeg($image);
        imagedestroy($image);
        imagedestroy($watermark);
    }
}

water_mark::apply('img1.gif','logo.gif');
Mukesh Variya
Zend Framework and Offshore Web Developer Ahmedabad Gujarat India
Customize Application Development Ahmedabad Gujarat India
http://mukeshvariya.blogspot.com
http://www.mukeshvariya.com
2 PR Blog Link Exchange with my blog

Post Reply