|
Posted by ZabMilenko on 10/08/06 13:55
Here is what I am seeing:
while($filename=mysql_fetch_array($result))
{
for($i=0;$i<=count($filename);$i++)
{
// loop thru a bunch of files
list($width, $height) = getimagesize($filename[$i]);
// find out how big it is
// Make an new image IN MEMORY
$image_p = imagecreatetruecolor($new_width, $new_height);
// make an image IN MEMORY from the original
$image = imagecreatefromjpeg($filename[$i]);
// Paint the image as a thumbnail IN MEMORY
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);
// Send the new image to the browser
imagejpeg($image_p, null, 100)."\n";
imagedestroy($image);
imagedestroy($image_p);
}
// Repeat
}
The problem is you can only send one image per request. That is ONE image
between header("content-type ...") and imagejpeg()
You can make all you want, but only the first will go to the browser. The
rest is as useless as spam.
So you need to dump the thumbnails to disk and load them another way.
ljuljacka wrote:
> The thing I'm trying to get is to display images as thumbnails without
> actually saving them, and the script does that but only with the first
> image.
> When I echo $filename[$i] inside the for loop it displays all file
> locations.
> When I removed imagedestroy() from script, it still does the same...
> So the problem is displaying other images.
>
> If this answer is funny it's because I don't know if I understood you
> correctly :)
>
> "ZabMilenko" wrote in message :
>> It looks as if you are creating the second image, but not saving it
>> anywhere.
>>
>> This generates an image: imagejpeg($image_p, null, 100)."\n";
>>
>> But what about $image? You do a copyresampled then destroy it. If you
>> want to save the image, pass the second argument to imagejpeg.
>>
>>
>
>
Navigation:
[Reply to this message]
|