Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 13th, 2005, 03:05 AM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 7 Creating background using imagefilter...

I altered 'gallery.php' on so that the background would have a faded black and white image of the first thumbnail. It does look kind of tacky but I am just playing around.

When I clicked on that thumbnail, instead of the thumbnail opening in color it was the faded black and white image of the background. In fact, the more I ran gallery.php the fainter my background image got so it finally became white.

I did use 'imagedestroy' but it didn't destroy anything.

How can I use image as a background black and white but keep the original image color?

Here is the altered code:

<?php
//connect to database
  $link = mysql_connect("localhost","cshu","holy****")
    or die("Could not connect: " . mysql_error());
  mysql_select_db("moviesite", $link)
    or die(mysql_error());

$ImageDir = "images/";
$ImageThumb = $ImageDir . "thumbs/";

$getbackgroundpic = mysql_query("SELECT * FROM images order by image_id desc")
  or die(mysql_error());
$rows = mysql_fetch_array($getbackgroundpic);
extract($rows);
$background_image_id = $image_id;


$background_image = $ImageDir . $background_image_id . ".jpg";

// converting the background image to greyscale is a bit tricky!!!!

$im = imagecreatefromjpeg($background_image);
if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)&&
   imagefilter($im, IMG_FILTER_BRIGHTNESS, 80)&&
   imagefilter($im,IMG_FILTER_GAUSSIAN_BLUR)) {
   echo 'Image converted to grayscale.';
   imagejpeg($im, $background_image);
} else {
   echo 'Conversion to grayscale failed.';
}

if (imagedestroy($im)) {
  echo 'Destroying the image now';
}
else {
  echo 'Did not destroy the image!';
}

?>

<html>
<head>
<title>Welcome to our Photo Gallery</title>

<style type="text/css">

body {
  background-image: url(<?php echo $background_image ?>);
  background-position: 50%;
}

table {border:1px solid red; padding:5px; width:90%;}
tr {background-color: #333;}
td {background-color; #ccc; border: 1px solid black;}
.highlight {background-color: transparent;}

</style>
</head>
<body>
  <p lign="center">Click on any image to see it full sized.</p>
  <table align="center">
    <tr>
      <td align="center" <Image</td>
      <td align="center"<Caption</td>
      <td align="center"<Uploaded By</td>
      <td align="center"<Date Uploaded</td>
    </tr>


<?php
//get the thumbs
$getpic = mysql_query("SELECT * FROM images")
  or die(mysql_error());
while ($rows = mysql_fetch_array($getpic)) {
  extract($rows);

  echo "<tr>\n";
  echo "<td><a href=\"".$ImageDir . $image_id . ".jpg\">";
  echo "<img src=\"" . $ImageThumb . $image_id . ".jpg\" border=\"0\">";
  echo "</a></td>\n";
  echo "<td class=\"highlight\">" . $image_caption . "</td>\n";
  echo "<td>" . $image_username . "</td>\n";
  echo "<td>" . $image_date . "</td>\n";
  echo "</tr\n";
}
?>
</table>
</body>
</html>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 10 - Creating Registry Keys InfinityLtd BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 July 9th, 2008 12:32 PM
Chapter 7 imagefilter function error magicfun BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 February 24th, 2008 09:16 PM
Ch 11 creating a user reg script ed123 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 September 28th, 2007 11:36 AM
CH. 4 Creating Local Variables mcauliff BOOK: Beginning ASP 3.0 1 March 3rd, 2005 03:57 PM
Ch. 4 -1. Creating a Table jfr BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 February 16th, 2005 02:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.