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 .
October 18th, 2006, 01:18 PM
Registered User
Join Date: Oct 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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
November 5th, 2006, 01:49 AM
Registered User
Join Date: Nov 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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.
November 24th, 2006, 08:26 PM
Registered User
Join Date: Oct 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off