Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 18th, 2006, 01:18 PM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 7, THUMBNAILS

i have everything working great, except the fact my server doesnt have php 5 so i cant use the imagefilter() ANYWAY my problem..

i am creating the images perfectly, but my thumbnails are not being created.

permissions are 777 on both images and thumbs

so i am coming out with a page that doesnt show the thumbnails but everything else (links) working fine.

$ImageDir ="images/";

$ImageThumb = $ImageDir . "thumbs/";

$ImageName = $ImageDir . $image_tempname;

  $lastpicid = mysql_insert_id();

  $newfilename = $ImageDir . $lastpicid . ".jpg";

  if ($type == 2) {
    rename($ImageName, $newfilename);
  } else {
    if ($type == 1) {
      $image_old = imagecreatefromgif($ImageName);
    } elseif ($type == 3) {
      $image_old = imagecreatefrompng($ImageName);

    $image_jpg = imagecreatetruecolor($width, $height);
    imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,
                     $width, $height, $width, $height);
    imagejpeg($image_jpg, $newfilename);
    imagedestroy($image_old);
    imagedestroy($image_jpg);
  }

 $newthumbname = $ImageThumb. $lastpicid . ".jpg";

  $thumb_width = $width * 0.10;
  $thumb_height = $height * 0.10;

  $largeimage = imagecreatefromjpeg($newfilename);
  $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
  imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0,
                    $thumb_width, $thumb_height, $width, $height);
  imagejpeg($thumb, $newthumbname);
  imagedestroy($largeimage);
  imagedestroy($thumb);

what i need is to know why the thumbnails are not working.
thanks for any help you can give.

also if using the code from the book i have to many { 's

richard

Reply With Quote
  #2 (permalink)  
Old November 5th, 2006, 01:49 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:
Code:
  if ($type == 2) {
    rename($ImageName, $newfilename);
    }
   else {
    if ($type == 1) {
      $image_old = imagecreatefromgif($ImageName);
      }
     elseif ($type == 3) {
       $image_old = imagecreatefrompng($ImageName);
 
       $image_jpg = imagecreatetruecolor($width, $height);
       imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,
                       $width, $height, $width, $height);
       imagejpeg($image_jpg, $newfilename);
       imagedestroy($image_old);
       imagedestroy($image_jpg);
       }
Well, if this is the exact code you are using, you are short quite a '}' As it stands, your original if statement's else clause is not closed, causing everything that follows to be included in the else clause. You actually have two solution possible here, this is what I think should be done:

Code:
  if ($type == 2) {
    rename($ImageName, $newfilename);
  } elseif ($type == 1) {
      $image_old = imagecreatefromgif($ImageName);
  } elseif ($type == 3) {
      $image_old = imagecreatefrompng($ImageName);
  }
    $image_jpg = imagecreatetruecolor($width, $height);
    imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0,
                     $width, $height, $width, $height);
    imagejpeg($image_jpg, $newfilename);
    imagedestroy($image_old);
    imagedestroy($image_jpg);


YUou could also try switching that statement to a 'switch' statement for maintainability.

Reply With Quote
  #3 (permalink)  
Old November 24th, 2006, 08:26 PM
Registered User
 
Join Date: Oct 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok... i got the same problem when im going to create the thumbnails

the code is:

$largeimage = imagecreatefromjpeg($newfilename);

and the error is:

Fatal error: Call to undefined function: imagecreatefromjpeg()

i dont know why if in my php.ini the library php_gd2.dll is not commented please help

Reply With Quote
Reply


Thread Tools
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
Paginate function with thumbnails dragon_rouge BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 March 13th, 2008 07:52 PM
Quicker way of loading thumbnails katsarosj Pro VB.NET 2002/2003 3 June 29th, 2005 09:42 AM
thumbnails without gd library? cutesneakers PHP How-To 1 January 14th, 2005 04:34 AM
Question for thumbnails and pictures on website Varg_88 Classic ASP Basics 3 December 28th, 2004 03:16 AM
How do you represent thumbnails and image maps? mountainbiker XSLT 0 June 17th, 2004 07:22 AM



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


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