Jump to content

Creating Watermark With Another Image & Resizing Watermarked Image


phpQuestioner

Recommended Posts

Ok - So I have a script that watermarks an image; it adds a transparent gif over my base image. I also have a script to resize my image. But here is where the problem comes in; these are two different scripts - none of the code will interconnect (variable wise - that is), so I am having a problem trying to piece together a PHP GD Image code that will create a watermark and will then be resized. Below is my code for resizing my image, but from there - I know I need to use imagecreategif somewhere and imagecopy somewhere; but where, I do not know.

 

<?php

$pw = $_GET['pw'];
$ph = $_GET['ph'];

$percent1 = $pw;
$percent2 = $ph;

// Content type
header('Content-type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width - $percent1;
$newheight = $height - $percent2;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb);

?>

Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.