Jump to content

Splash marks on images?


hlstriker

Recommended Posts

Hi, I did exactly what that first tutorial said and thousands of symbols display on my page instead of the image. I don't get any errors or warnings, just thousands of symbols. Here is the code I used... (note I had to put another header after the image was created otherwise nothing would display on my page.)

 

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

$watermark = imagecreatefrompng('watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatefromjpeg("path/to/image");
$size = getimagesize("path/to/image");
$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);

header('content-type: text/html');

echo "<img src='$image'>";

Link to comment
Share on other sites

 

example link of a dear water marked dead friend.

http://www.freelanceprogrammers.co.uk/font/

 

dont need all that code here you go

 

<?php 
$im    = imagecreatefrompng("mat_picture.png");
$yellow = ImageColorAllocate ($im, 235, 235, 51);
$saying="hi there i am redarrow"; 
ImageTTFText ($im, 15, 1, 25, 70, $yellow, "/WINDOWS/Fonts/IMPACT.ttf", "$saying"); 
ImagePNG($im); 
?> 

Link to comment
Share on other sites

Put image code in a file of its own

 

:: wm_image.php ::

<?php

$image = $_GET['image'];

$watermark = imagecreatefrompng('watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatefromjpeg($image);
$size = getimagesize($image);
$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);

header('content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
?>

 

in another file, place image on page

 

:: another.php ::

<?php

echo '<img src="wm_image.php?image=path/to/image">';

?>

Link to comment
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.