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.
|