Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2003, 09:44 PM   PM User | #1
Shecky
Regular Coder

 
Join Date: Dec 2002
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Shecky is an unknown quantity at this point
gd image to watermark image?

is there a method in gd to change an image into a watermark image?

i'm wishing to create an automated process where and image would be automatically converted to 20% opacity against a white matte.
__________________
seldom ruined but by myself
Shecky is offline   Reply With Quote
Old 03-24-2003, 10:01 PM   PM User | #2
Ökii
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 577
Thanks: 0
Thanked 0 Times in 0 Posts
Ökii is an unknown quantity at this point
you want to iterate through the image pixel by pixel and then imagecopymerge a sampling over a plain white base

PHP Code:
<?php
$resource 
'whatever.jpg';
$opacity 20;
$siz getimagesize($resource);
$basei imagecreatefromjpeg($resource);
$newi imagecreatetruecolor($siz[0],$siz[1]);
$whit imagecolorallocate($newi255255255);
for(
$dy 0$dy $siz[1]; $dy++)
 {
 for(
$dx 0$dx $siz[0]; $dx++)
  {
  
imagecopymerge($newi$basei$dx$dy$dx$dy11$opacity);
  }
 }
imagedestroy($basei);
imagejpeg($newi'folder/save.jpg'85);
imagedestroy($newi);
?>
fly typed so will probably parse bad, should point you in the right direction though.
subnote - GD2 functions used.

-------------
edit - you wouldn't need to iterate really - lose the for loops and just use

imagecopymerge($newi, $basei, 0, 0, 0, 0, $siz[0], $siz[1], $opacity);
__________________
Ökii - formerly pootergeist
teckis - take your time and it'll save you time.

Last edited by Ökii; 03-24-2003 at 10:04 PM..
Ökii is offline   Reply With Quote
Old 03-24-2003, 10:56 PM   PM User | #3
Shecky
Regular Coder

 
Join Date: Dec 2002
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Shecky is an unknown quantity at this point
:)

THANK YOU, COOL PERSON!
__________________
seldom ruined but by myself
Shecky is offline   Reply With Quote
Old 11-03-2003, 02:48 AM   PM User | #4
win555
New Coder

 
Join Date: Jan 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
win555 is an unknown quantity at this point
Watermark

This is very cool...

But is there a way to embed the watermark on the top of the image, you know like to have a JPG with a watermark on the top...

And also be able to control the quality and opacity based on the color that we don't want to be visible...

Also I forgot I have GD. 1.6 so imagecreate() is what works not imagecreateTrueColor()

Please help
Any ideas?
win555 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:46 AM.


Advertisement
Log in to turn off these ads.