使用方法
$img = new iamge;
$img
說明
$img
說明
這個是針對GD庫才這樣麻煩的
<?php
class image{
public function resize($dstImg
list($srcW
$scale = min($dstW/$srcW
$newW = round($srcW * $scale);
$newH = round($srcH * $scale);
$newImg = imagecreatetruecolor($newW
$srcImg = imagecreatefromjpeg($srcImg);
imagecopyresampled($newImg
imagejpeg($newImg
}
public function thumb($dstImg
list($srcW
$scale = max($dstW/$srcW
$newW = round($dstW/$scale);
$newH = round($dstH/$scale);
$x = ($srcW
$y = ($srcH
$newImg = imagecreatetruecolor($dstW
$srcImg = imagecreatefromjpeg($srcImg);
imagecopyresampled($newImg
imagejpeg($newImg
}
}
function createFromType($type
$function = "imagecreatefrom$type";
return $function($srcImg);
}
//為了解決不同圖片格式的問題
From:http://tw.wingwit.com/Article/program/PHP/201311/21312.html