Сабж. Не хочет делать маленькие картинки.
Поправьте меня, если что не так.
$gd_version = 2;
class thumbnail
{
var $img;
var $watermark_image_light;
var $watermark_image_dark;
function thumbnail($imgfile)
{
//detect image format
$this->img["format"]=ereg_replace(".*\\.(.*)$","\\\\1",$imgfile);
$this->img["format"]=strtoupper($this->img["format"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
$this->img["format"]="JPEG";
$this->img["src"] = ImageCreateFromJPEG ($imgfile);
} elseif ($this->img["format"]=="PNG") {
//PNG
$this->img["format"]="PNG";
$this->img["src"] = ImageCreateFromPNG ($imgfile);
} elseif ($this->img["format"]=="GIF") {
//GIF
$this->img["format"]="GIF";
$this->img["src"] = ImageCreateFromGIF ($imgfile);
} else {
//DEFAULT
echo "Not Supported File! Thumbnails can only be made from .jpg and .png images!";
exit();
}
$this->img["lebar"] = imagesx($this->img["src"]);
$this->img["tinggi"] = imagesy($this->img["src"]);
$this->img["lebar_thumb"] = $this->img["lebar"];
$this->img["tinggi_thumb"] = $this->img["tinggi"];
//default quality jpeg
$this->img["quality"]=90;
}
function size_auto($size=100)
{ global $gd_version;
if ($this->img["lebar"] < $size AND $this->img["tinggi"] < $size ) {
$this->img["lebar_thumb"] = $this->img["lebar"];
$this->img["tinggi_thumb"] = $this->img["tinggi"];
return 0;
} elseif ($this->img["lebar"]>=$this->img["tinggi"])
{
$this->img["lebar_thumb"]=$size;
$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
} else {
$this->img["tinggi_thumb"]=$size;
$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
}
if($gd_version==1)
{
$this->img["des"] = imagecreate($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
@imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
}
elseif($gd_version==2)
{
$this->img["des"] = imagecreatetruecolor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
@imagecopyresampled ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
}
$this->img["src"] = $this->img["des"];
return 1;
}
function jpeg_quality($quality=90)
{
//jpeg quality
$this->img["quality"]=$quality;
}
function save($save="")
{
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
imageJPEG($this->img["src"],"$save",$this->img["quality"]);
} elseif ($this->img["format"]=="PNG") {
//PNG
imagePNG($this->img["src"],"$save");
} elseif ($this->img["format"]=="GIF") {
//GIF
imageGIF($this->img["src"],"$save");
}
imagedestroy($this->img["src"]);
}
function show ()
{
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
imageJPEG($this->img["src"],"",$this->img["quality"]);
} elseif ($this->img["format"]=="PNG") {
//PNG
imagePNG($this->img["src"]);
} elseif ($this->img["format"]=="GIF") {
//GIF
imageGIF($this->img["src"]);
}
imagedestroy($this->img["src"]);
}
?>