Lav thumb virker ikke
Hejsa.Hvis i kigger her: http://www.babegalleri.dk/test/images/users/hotornot/index.php?img_id=1
Så ser i at min funktion sætter det lille billede i hjørnet på, men hvis jeg prøver at lave en thumb, som her: http://www.babegalleri.dk/test/images/users/hotornot/index.php?img_id=1&thumb=ture Så skulle den gerne lave den til 130 bred også højden så den passer, men den gør slet ikke noget ved billedet. Den viser det bare. Nogle der kan finde fejlen?
Kode:
<?
include('../../../sql.php');
$img_id = $_GET['img_id'];
$thumb = $_GET['thumb'];
$query = mysql_query("SELECT * FROM hotornot WHERE id = '$img_id' AND img_accepted = 'yes'") or die(mysql_error());
$mappe = "images/";
if(mysql_num_rows($query) == 0) {
header("Location:http://babegalleri.dk");
exit;
} else {
$row = mysql_fetch_assoc($query);
if($row['img_type'] == ".gif") {
header('content-type: image/gif');
} else {
header('content-type: image/jpg');
}
if($thumb == "true") {
if($row['img_type'] == ".gif") {
$type = ".gif";
$image = imagecreatefromgif($mappe.$img_id.$type);
} else {
$type = ".jpg";
$image = imagecreatefromjpeg($mappe.$img_id.$type);
}
$x = imagesx($image);
$y = imagesy($image);
$img_width = 130;
$calculate = $img_width / $x;
$img_height = round($y * $calculate,0);
$logo = imagecreatetruecolor($img_width,$img_height);
imagecopyresampled($logo,$image,0,0,0,0,$img_width,$img_height,$x,$y);
} else {
$logo = imagecreatefromgif('logo.gif');
$logo_width = 120;
$logo_height = 25;
$image = imagecreatetruecolor($logo_width, $logo_height);
if($row['img_type'] == ".gif") {
$type = ".gif";
$image = imagecreatefromgif($mappe.$img_id.$type);
} else {
$type = ".jpg";
$image = imagecreatefromjpeg($mappe.$img_id.$type);
}
$size = getimagesize($mappe.$img_id.$type);
$dest_x = $size[0] - $logo_width;
$dest_y = $size[1] - $logo_height;
imagecopymerge($image, $logo, $dest_x, $dest_y, 0, 0, $logo_width, $logo_height, 100);
}
if($row['img_type'] == ".gif") {
imagegif($image);
} else {
imagejpeg($image);
}
imagedestroy($image);
imagedestroy($logo);
}
?>