fejl: min fejl.. undskyld.
jeg har lige hentet koden. og prøvet det med
http://www.dulmens.dk/tobias/test.php?image=ying_yang.jpg&width=300&height=300og det virker fino.
koden ser ud som følger hos mig:
<?php
/*************************************************************\
* Image resizer, version 2.0 - Mar9,2003 *
* Returns true on success, false if there are errors *
* If destination file is specified, resized picture will be *
* saved with the specified name. Else, it is shown to browser *
* Version 2: Now scales both up and down, still preserving *
* aspect ratio, and it accepts not only jpeg, but *
* also png and possibly bmp *
}*************************************************************{
* Created by XyborX (
www.xyborx.dk) *
* Feel free to use, modify and distribute, without profit. *
* I cannot be held liable for any damage this script might do *
\*************************************************************/
function imageresize($sourcefile,$maxwidth,$maxheight,$destinationfile=false)
{
$types=Array();
$types[1]='gif';
$types[2]='jpeg';
$types[3]='png';
$types[6]='wbmp';
list($width,$height,$type)=getimagesize($sourcefile);
$type_name=$types[$type];
$imagecreatefromtype='imagecreatefrom'.$type_name;
$imagetype='image'.$type_name;
if(!function_exists($imagecreatefromtype) || !function_exists($imagetype))
{
return false;
}
if($img_src=$imagecreatefromtype($sourcefile))
{
$ratio_height=$maxheight/$height;
$ratio_width=$maxwidth/$width;
$ratio=min($ratio_width,$ratio_height);
$newwidth=$width*$ratio;
$newheight=$height*$ratio;
$img_dst=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
if($destinationfile==false)
{
//header("Content-type: image/jpeg");
$imagetype($img_dst);
}
else
$imagetype($img_dst,$destinationfile);
imagedestroy($img_dst);
return true;
}
else
{
return false;
}
}
// Code below is only to demonstrate usage
if(!extension_loaded('gd'))
{
echo 'Sorry, The GD-extension must be loaded for this to work..';
}
else
{
if($_GET['image'])
{
$file='img/'.str_replace(array(' ','/','\\'),'',$_GET['image']);
$width=intval($_GET['width'])>0?intval($_GET['width']):150;
$height=intval($_GET['height'])>0?intval($_GET['height']):150;
if(!imageresize($file,$width,$height))
echo 'Fejl. Kunne ikke åbne: <b><a href='.$file.'>'.$file.'</a></b>';
}
}
?>
det eneste jeg har ændret er
$file='pic/'.str_replace(array(' ','/','\\'),'',$_GET['image']);
til
$file='img/'.str_replace(array(' ','/','\\'),'',$_GET['image']);