Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » generating thumbnails (PHP)
Closed Thread
Old 12-13-2005, 11:23 PM   #1 (permalink)
 
True Techie

Join Date: Apr 2005

Posts: 110

Murdoc

Default generating thumbnails (PHP)

Hello everyone,

I'm trying to make a script that will generate thumbnails. I've suceeded about half way and failed. Why? The problem is because I can't save properly.

I want the thumbnail to be generated and then SAVED as a new version of jpg.

IE:
1) p01.jpg <- original file

becomes

2) p01th.jpg <- resized file

When I try to save I used this command

ImageJpeg ($final_image, "p01th.jpg",100);

it generates the file perfectly and saves just like I wanted it to, but then generates an error as well saying:

Cannot display picture from ../../../thumbnails/makethumbnails.php because it contains errors.

This means it must have tried to output the image to the browser, but the thing is I don't want it to output to browser. All I want it to say is "Finished generating thumbnails." and save all the generated thumbnails as .jpg files and that's it. Does anyone know why this happens? When I take away the "p01th.jpg" part, I am able to see the new thumbnail on browser but it doens't get saved = / please help!!
Murdoc is offline  
Old 12-14-2005, 12:00 AM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,389

office politics will become famous soon enough

Default

http://us2.php.net/imagejpeg
PHP Code:
//Grab new image
ob_start();
ImageJPEG($new_image);
$image_buffer ob_get_contents();
ob_end_clean();
ImageDestroy($new_image);
//Create temporary file and write to it
$fp tmpfile();
fwrite($fp$image_buffer)) {
rewind($fp); 

office politics is offline  
 
Closed Thread

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