Jump to content

watermarking an image


Suchy

Recommended Posts

I have a simple script which adds a watermark to images:

$my_text = 'www.mywebsite.com';

$img = imagecreatefromjpeg ('image5.jpg');
$white = imagecolorallocate($img, 255, 255, 255); 
imagestring($img, 4, 6, 3, $my_text, $white); 

header("Content-type: image/jpeg");
imagejpeg($img);
imagedestroy($img);

 

This works great, however when I put it inside a foreach loop and change the $img variable to:

$img = imagecreatefromjpeg($temp_var['url']);

 

Instead of the image with thw watermark I get

Warning: Cannot modify header information - headers already sent by (output started at /home/suchygn/public_html/photos/show.php:88) in /home/suchygn/public_html/photos/show.php on line 159

ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222 222222222222222222222222222222222222ÿÀxx"ÿÄ ÿĵ }!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEF

 

How can this be fixed ?

Link to comment
https://forums.phpfreaks.com/topic/49139-watermarking-an-image/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.