Skip to content
WJunction - Webmaster Forum

Watermark Image On Upload

Status
Not open for further replies.
Hi

ive written the function:

PHP:
    //Watermark the image...
function add_watermark($image) {
    $overlay = "site_images/imgcafe_watermark.gif";
    
    $w_offset = 0;
    $h_offset = 0;
    
    $extension = strtolower(substr($image, strrpos($image, ".") +1));
    
    switch ($extension)
    {
        case 'jpg':
        $background = imagecreatefromjpeg($image);
        break;
        case 'gif':
        $background = imagecreatefromgif($image);
        break;
        case 'png':
        $background = imagecreatefrompng($image);
        break;
        default:
        die("Image type not supported");
    }
    
    $base_width = imagesx($background);
    $base_height = imagesy($background);
    imagealphablending($background, true);
    
    $overlay = imagecreatefromgif($overlay);

    imagesettile($background, $overlay);

// Make the image repeat
imagefilledrectangle($background, 0, 0, $base_width, $base_height, IMG_COLOR_TILED);
header('Content-type: image/png');
imagepng($background);


}

problem is its not watermarking anything nor showing any errors.

any help?>
 

1 comment

Status
Not open for further replies.

About the author

C
Banned · Joined
901
Messages
17
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom