Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Creating thumbnails problem (yet another one)
Old 08-16-2006, 03:33 PM Creating thumbnails problem (yet another one)
Junior Talker

Posts: 2
Trades: 0
I've really made an over-a-google-research about my problem but i still have no clue.

Actually, i can create thumbnails, but in the way i don't like much:
<image src="thumbnail_script.php?image=$image">

I want to have smth like this:
<image src=show_thumbnail($image)>

What i'm trying to do:
PHP Code:
function show_thumbnail($image_path){
    
    list(
$width,$height) = getimagesize($image_path);
        
$new_height 75;
        
$k $new_height $height;
        
$new_width $width $k;


        
$image_thumb imagecreatetruecolor($new_width,$new_height);
        
$image_thumb_tmp imagecreatetruecolor($new_width,$new_height);
        
$image imagecreatefromjpeg($image_path);
        
imagecopyresampled($image_thumb,$image,0,0,0,0,$new_width,$new_height,$width,$height);

//     header('Content-type: image/jpeg', true);
        
imagejpeg($image_thumb''100);
        
imagedestroy($image_thumb);
    } 
I get either raw data or "header already sent" error - when i use header('Content-type: image/jpeg', true);

I need to have a function which returns an image, rather then a raw data. I don't want to save this temporary-thumb-file to disk as well.

Does anybody has a clue if it is possible?

Thank you.
dummy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-17-2006, 07:18 AM Re: Creating thumbnails problem (yet another one)
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
You cannot make a function which returns an image. You cannot mix php and html in a way like this since php works on server and generates html which is parsed on client. Look at source of any page which contains images to get the idea. You will have either to generate ready static images and write img src="/path/to/thumnail.jpg" or to write img src="/path/to/thumbnail/script.php?image=123" and within the script.php create resized image and send it to client as binary stream.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-17-2006, 07:20 AM Re: Creating thumbnails problem (yet another one)
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
And why don't you want to save the file to disk? This is preferred a lot because it makes less load for your server. Do you know that apache on average hardware can process (give away) about 1000 static files per second and hardly 50 image-generating php scripts?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-17-2006, 11:54 AM Re: Creating thumbnails problem (yet another one)
Junior Talker

Posts: 2
Trades: 0
Thanks.
I'm going to save them to disk.
dummy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Creating thumbnails problem (yet another one)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32614 seconds with 12 queries