Jeg har gang i XyborX skallerings script. Jeg har selv gjort nogle forsøg, der stort set er lykkes. Mit problem er at den udskriver en hel masse mærkelig kode.
Er det på noget måde muligt at fjerne den mærkelige kode?
kan ses på [url=http://kibaektbk.wep.dk/test/galleri/test.php]kibaektbk.wep.dk/test/galleri/test.php[/url] (Billedet er helt nede i bunden af siden)
resizer.php
<?php
session_start();
/*************************************************************\\* Image resizer, version 2.1 - May10,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 *
* Version 2.1: Genereal optimization and bugfixing. *
* No longer requires GD-lib to be >=2.0.1 *
}*************************************************************{
* 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;
if(function_exists('imagecreatetruecolor'))
{
$img_dst=imagecreatetruecolor($newwidth,$newheight);
}
elseif(function_exists('imagecreate'))
{
$img_dst=imagecreate($newwidth,$newheight);
}
else
{
return false;
}
if(function_exists('imagecopyresampled'))
{
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
elseif(function_exists('imagecopyresized'))
{
imagecopyresized($img_dst, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
else
{
imagedestroy($img_src);
imagedestroy($img_dst);
return false;
}
if($destinationfile==false)
{
header('Content-type: '.image_type_to_mime_type($type));
$imagetype($img_dst);
}
else
{
$imagetype($img_dst,$destinationfile);
}
imagedestroy($img_src);
imagedestroy($img_dst);
return true;
}
else
{
return false;
}
}
imageresize($_SESSION['sourcefile'],$_SESSION['$maxwidth'],$_SESSION['$maxheight']);
?>
test.php
<?php
session_start();
?>
<html>
<head>
</head>
<body>
<?php
include("resizer.php");
$_SESSION['$maxwidth'] = 1000; # Maximal width of miniatures
$_SESSION['$maxheight'] = 1000; # Maximal height of miniatures
$_SESSION['sourcefile'] = "DSC01197.JPG";
echo"et skalleret billed<br /><img src='resizer.php' />";
?>
</body>
</html>
Indlæg senest redigeret d. 01.12.2007 01:55 af Bruger #10878