PHP生成图片缩略图方法及代码 (3)
else
//不裁图
{
if( $ratio>= $resize_ratio)
{
$newimg = imagecreatetruecolor( $this->resize_width,( $this->resize_width)/ $ratio);
imagecopyresampled( $newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ( $this->resize_width)/ $ratio, $this->width, $this->height);
ImageJpeg ( $newimg, $this->dstimg);
}
if( $ratio< $resize_ratio)
{
$newimg = imagecreatetruecolor(( $this->resize_height)* $ratio, $this->resize_height);
imagecopyresampled( $newimg, $this->im, 0, 0, 0, 0, ( $this->resize_height)* $ratio, $this->resize_height, $this->width, $this->height);
ImageJpeg ( $newimg, $this->dstimg);
}
}
}
//初始化图象
function initi_img()
{
if( $this->type=="jpg")
{
$this->im = imagecreatefromjpeg( $this->srcimg);
}
if( $this->type=="gif")
{

[
1] [
2]
[3] [
4]
