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 October 18th, 2006, 01:18 PM
Registered User
 
Join Date: Oct 2006
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

 
Old November 5th, 2006, 02:49 AM
Registered User
 
Join Date: Nov 2006
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.

 
Old November 24th, 2006, 09:26 PM
Registered User
 
Join Date: Oct 2005
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






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 05:34 AM
Question for thumbnails and pictures on website Varg_88 Classic ASP Basics 3 December 28th, 2004 04:16 AM
How do you represent thumbnails and image maps? mountainbiker XSLT 0 June 17th, 2004 07:22 AM





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