hlstriker Posted June 30, 2007 Share Posted June 30, 2007 Hi, is there a way to put a splash mark on an image that is already uploaded to my website? I really don't even know where to start with this, so sorry if I didn't explain enough. Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/ Share on other sites More sharing options...
pocobueno1388 Posted June 30, 2007 Share Posted June 30, 2007 Here are some tutorials http://www.sitepoint.com/article/watermark-images-php http://www.devshed.com/c/a/PHP/Dynamic-Watermarking-with-PHP/ Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286706 Share on other sites More sharing options...
hlstriker Posted June 30, 2007 Author Share Posted June 30, 2007 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 https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286716 Share on other sites More sharing options...
redarrow Posted June 30, 2007 Share Posted June 30, 2007 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 https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286722 Share on other sites More sharing options...
Barand Posted June 30, 2007 Share Posted June 30, 2007 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 https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286756 Share on other sites More sharing options...
redarrow Posted June 30, 2007 Share Posted June 30, 2007 barand i no you sent me a pm i hope you got mine today? is my code so bad? Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286759 Share on other sites More sharing options...
Barand Posted June 30, 2007 Share Posted June 30, 2007 ~redarrow, Apart from missing content-type header, and if you only want a text-only watermark at the top left, it looks fine. The extra (uneccessary, as you say) code as posted is to place an image as a watermark relative to the bottom right of an image Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286768 Share on other sites More sharing options...
redarrow Posted June 30, 2007 Share Posted June 30, 2007 ok thanks. Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286773 Share on other sites More sharing options...
hlstriker Posted June 30, 2007 Author Share Posted June 30, 2007 Thanks for all the help so far, I've got it working. I have another question though. Is it possible to resize the image without saving it to the harddrive? Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286790 Share on other sites More sharing options...
hlstriker Posted June 30, 2007 Author Share Posted June 30, 2007 Ok I used... imagecopyresized($dest, $img, 0, 0, 0, 0, 350, 300, $size[0], $size[1]); It worked but now the images color is all messed up. Is there a way to do this with keeping the original color? Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286830 Share on other sites More sharing options...
Barand Posted June 30, 2007 Share Posted June 30, 2007 Create the dest image with imagecreatetruecolor You might find imagecopyresampled works better too Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286832 Share on other sites More sharing options...
hlstriker Posted June 30, 2007 Author Share Posted June 30, 2007 Works perfect, thanks Link to comment https://forums.phpfreaks.com/topic/57860-splash-marks-on-images/#findComment-286836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.