Jump to content

sayen

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by sayen

  1. I've got a script that auto-puts watermark on images code: <?php //get stuff $src = $_SERVER['DOCUMENT_ROOT'].'/'.$_GET['src']; $watermarkSRC = 'img/wm.png'; header('Content-type: image/jpeg'); //create watermark $watermark = imagecreatefrompng($watermarkSRC); //wm dimensions $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); //border $border=25; //some crappy logic if(strpos($src,'.gif') !== false) { $image = imagecreatefromgif($src); } elseif(strpos($src,'.jpeg') !== false || strpos($src,'.jpg') !== false) { $image = imagecreatefromjpeg($src); } elseif(strpos($src,'.png') !== false) { $image = imagecreatefrompng($src); } else { exit("Your image is not a gif, jpeg or png image. Sorry."); } //image dimensions $width=ImageSx($image); $height=ImageSy($image); //lets make a border $img_adj_height=$height+$border; $square=imagecreatetruecolor($width,$img_adj_height); //border + image imagecopyresampled($square, $image, 0, 0, 0, 0, $width, $img_adj_height, $width, $img_adj_height); //watermark placement $dest_x = $width - $watermark_width - 5; $dest_y = $img_adj_height - $watermark_height - 5; //border + watermark imagecolortransparent($watermark,imagecolorat($watermark,0,0)); imagecopyresampled($square, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height); //wrap up imagejpeg($square, "", 100); imagedestroy($image); imagedestroy($watermark); ?> and I want to change it so the watermark will be in a border with the transparent or white background instead of black how can I do that?
  2. I knew that it was a simple thing. Works like a charm, thanks!
  3. 15 rows selected from the table. I want to randomly display an ad between them. Here's the code: $count = 1; (mysql select rows) $number = rand (1,15); if ($count == $number) { echo 'ad code '; } $count++; I want the ad to be displayed only once and in the above code, depending on the generated number by rand() matching the $number the ads will be displayed more times. How can I limit this only to one?
×
×
  • 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.