Thumb af billeder ??
Hejsa Nedenstående er et script jeg har fundet!Men det ser ikke ud til at fungere :-((
nogen der kan se nogle fejl / eller kan henvise til et andet script??
der komme ringen fejlmeddelse, men det viser heller ikke noget billede..... i det bib. jeg har placeret filen er der billeder af typpen : .jpg .jpeg .JPEG .JPG .gif .GIF
<?
//Images Wrapper for thumbs and other stuffs, require GDLib
//Riccardo Pasquini, 04/04/2001, v0.1
//r.pasquini@www.doublet.it
class DynaPic
{
var $m_sPicName;
var $m_sFormat;
var $m_hPic;
var $m_bHandled;
var $m_sLastError;
var $m_nThumbX;
var $m_nThumbY;
var $m_aHeaders;
function DynaPic($pic,$format)
{
//check if valid format
if(strtoupper($format)!=\"PNG\" && strtoupper($format)!=\"GIF\" && strtoupper($format)!=\"JPEG\")
{
$this->m_sLastError=\"Invalid format: \".stripslashes(htmlentities($format));
return false;
}
//initialize
$this->m_sFormat=strtoupper($format);
$this->m_sPicName=$pic;
$this->m_sLastError=\"\";
//thumb default resize 50%
$this->setThumbDimension(0.5);
$this->m_aHeaders=array(\"GIF\"=>\"Content-type: image/gif\",\"PNG\"=>\"Content-type: image/png\",\"JPEG\"=>\"Content-type: image/jpeg\");
return $this->create();
}
function destroy()
{
if($this->m_bHandled)
{
imagedestroy($this->m_hPic);
$this->m_bHandled=false;
}
}
function create()
{
$this->destroy();
eval(\"\\$this->m_hPic=@imagecreatefrom\".$this->m_sFormat.\"(\'\".$this->m_sPicName.\"\');\");
//check if init succeded
if(!$this->m_hPic)
{
$m_sLastError=\"Unable to open \".stripslashes(htmlentities($this->m_sPicName)).\" as \".stripslashes(htmlentities($this->m_sFormat));
$this->m_bHandled=false;
return false;
}
else
{
$this->m_bHandled=true;
return true;
}
}
//property access
function getLastError()
{
return $this->m_sLastError;
}
function setPicName($pic)
{
$this->m_sPicName=$pic;
$this->m_bHandled=false;
}
function getPicName()
{
return $this->m_sPicName;
}
function setThumbDimension($pctg)
{
$size = GetImageSize($this->m_sPicName);
$this->m_nThumbX=$size[0]*$pctg;
$this->m_nThumbY=$size[1]*$pctg;
}
function getThumbDimension(&$w,&$h)
{
$w=$this->m_nThumbX;
$h=$this->m_nThumbY;
}
function setPicFormat($format)
{
if(strtoupper($format)!=\"PNG\" && strtoupper($format)!=\"GIF\" && strtoupper($format)!=\"JPEG\")
{
$this->m_sLastError=\"Invalid format: \".stripslashes(htmlentities($format));
return false;
}
else
{
$this->m_sFormat=strtoupper($format);
$this->m_bHandled=false;
}
return true;
}
function getPicFormat()
{
return $this->m_sFormat;
}
//display functions
function thumb()
{
if($this->m_bHandled)
{
$size = GetImageSize($this->m_sPicName);
$picTmp=imagecreate($this->m_nThumbX,$this->m_nThumbY);
imagecopyresized($picTmp, $this->m_hPic, 0, 0, 0, 0, $this->m_nThumbX, $this->m_nThumbY, $size[0], $size[1]);
header($this->m_aHeaders[$this->m_sFormat]);
switch($this->m_sFormat)
{
case \'JPEG\':
imagejpeg($picTmp);
break;
case \'GIF\':
imagegif($picTmp);
break;
case \'PNG\':
imagepng($picTmp);
break;
}
imagedestroy($picTmp);
}
}
function full()
{
if($this->m_bHandled)
{
header($this->m_aHeaders[$this->m_sFormat]);
switch($this->m_sFormat)
{
case \'JPEG\':
imagejpeg($this->m_hPic);
break;
case \'GIF\':
imagegif($this->m_hPic);
break;
case \'PNG\':
imagepng($this->m_hPic);
break;
}
}
}
function view($width, $height)
{
if($this->m_bHandled)
{
$size = GetImageSize($this->m_sPicName);
$picTmp=imagecreate($width,$height);
imagecopyresized($picTmp, $this->m_hPic, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
header($this->m_aHeaders[$this->m_sFormat]);
switch($this->m_sFormat)
{
case \'JPEG\':
imagejpeg($picTmp);
break;
case \'GIF\':
imagegif($picTmp);
break;
case \'PNG\':
imagepng($picTmp);
break;
}
imagedestroy($picTmp);
}
}
}
?>
