Jump to content

Recommended Posts

Hello everyone,

 

I have finally gotten this GD watermarking script working the way I want (see: http://roygrahamphotography.com/wm_included.php?&src=img/roger/008.jpg&title=DSBC%20Orca%20Run%20at%20Shawnigan%20Lake&gal=roger) .. BUT, I can't get the output to display with CSS formatting or any other formatting for that matter.  I've tried everything that I can imagine and am at whit's end.  HELP.

I think it may have something to do with the line 10, 'header('content-type: image/jpeg');', not allowing anything else to be displayed.  Is there a workaround?

 

Here's the script (that matches the above link).  Thanks in advance...

_______________________________________________

<?php

 

// GETS

$gal = $_REQUEST['gal'];

 

// must be passed these VARS to work properly:

// 'src=[path/filename]&title=[any-title]&gal=[directory-of-image-files]'

 

function watermarked($gal) {

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

 

// VARS

$watermark = imagecreatefrompng('img/wm_rgp_sm.png'); //place path to your WM between the single quotes.

 

// create watermark image size

$watermark_width = imagesx($watermark); 

$watermark_height = imagesy($watermark);

 

// GETS

$image = imagecreatetruecolor($watermark_width, $watermark_height);

$image = imagecreatefromjpeg($_REQUEST['src']); // pass the 'src' parameter in an <a href> link like this, ie: <a href="yoursite.com?src=img2/DSC_0050.JPG"></a>

$title = $_REQUEST['title'];

//$dir = $_REQUEST['gal'];

//$full_path = "$dir/$image";

 

 

 

// Dimensions & Location of watermark in relation to IMG

    // dimension

$size = getimagesize($_REQUEST['src']); 

    // location

$dest_x = ($size[0] * 0.5) - ($watermark_width * 0.5);

$dest_y = ($size[1] * 0.95) - ($watermark_height * 0.5);

 

// Merge IMG and WM (if commented out, IMG shows up, but WM does not)

imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);

 

// OUTPUT merged image

imagejpeg($image); 

imagedestroy($image); 

imagedestroy($watermark);

 

/* TO CALL THIS FUNCTION, use below code in destination file:

// dynamically assign function to a variable.

$show_wm = "watermarked";

// dynamically call said function

$show_wm();

*/

}

 

// dynamically assign function to a variable.

$show_wm = "watermarked";

// dynamically call said function

$show_wm($gal);

 

 

?>

_______________________________________________

 

Link to comment
https://forums.phpfreaks.com/topic/104322-gd-watermarking-help/
Share on other sites

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.