Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 13th, 2005, 03:05 AM
Registered User
Join Date: Jun 2005
Location: , , .
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:

//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);
$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!';


<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;}

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

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

  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";

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 01:01 AM.

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