I have a prob with php+GD...
I want to show, into my php page, thumbnails of the images i have onto my server.
I'm using this function, as found in php.net:
- Code: Select all
function resizeImage($filename)
{
$width = 50;
$height = 50;
header('Content-type: image/jpeg');
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig))
{
$width = ($height / $height_orig) * $width_orig;
}
else
{
$height = ($width / $width_orig) * $height_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, null, 100);
}
Everything goes well, and if i try do do a resizeImage("img.jpg") i can correctly see the thumb.
My problem comes when i have to show a list of images whose URLs i get from a MySQL query.
If i do this:
- Code: Select all
$subQuery = "SELECT * FROM items WHERE tipo=1";
$subResult = mysql_query($subQuery, $db);
while ($subRow = mysql_fetch_array($subResult))
{
resizeImage ("../".$subRow[url]);
echo $subRow[url];
}
my thumbnail is shown in ASCII!!!!
If i don't insert the "echo line", my thumb is show correctly!
Instead of the images i get something like this:
ÿØÿàJFIFÿþ|Õµ_Í�Œü];xWÃ:¦ØØèS]
M6¥âA¿»–MMŠiìãÛ ”¶KÛ,Ê}ƒãŸí«û< þÍ7‰¥|bñkxoU›C›Ä°i‘xoǺ_̺ÐɨyÚW‚ï,£€O
Û§�y’L_ +Kòæ/þ
Anyone can help me?
Where's the mistake?


it will help 