php教程
class My_Lib_simpleimage {
var $image;
var $image_type;
function load($filename) {
//$filename 文件的临时文件名 $_FILES['name']['tmp_name']
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = imagecreatefrompng($filename);
}
}
function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image,$filename,$compression);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image,$filename);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image,$filename);
}
if( $permissions != null) {
chmod($filename,$permissions);
}
}
function output($image_type=IMAGETYPE_JPEG) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image);
}
}
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
#设置缩略图片高度
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
$this->resize($width,$height);
}
#设置缩略图片宽度
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function scale($scale) {
$width = $this->getWidth() * $scale/100;
$height = $this->getheight() * $scale/100;
$this->resize($width,$height);
}
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}
?>
太极熊猫2百度版 安卓版v1.7.1
下载黎明觉醒应用宝版 安卓版v1.111.1
下载暗影格斗3国际版 (Shadow Fight 3)最新版v1.40.3
下载王者战魂华为版 安卓版v3.6.1
下载放置魔法学院免广告版 v2.9.5
放置魔法学院内置Mod菜单是游戏的破解版本,在该版本中为玩家
万乘之国qq版本 安卓版v1.0.5
万乘之国qq版本是一款极具魅力的策略游戏,玩家们可以通过不同
动物餐厅国际服无限内购版 v12.9
动物餐厅国际服免广告版是游戏的破解版本,在该版本中为玩家去除
欧洲卡车司机 安卓版v3.2
欧洲卡车司机是款模拟经营游戏,这款游戏的画面还是蛮逼真的,给
疯狂大酒店 (Grand Hotel Mania)最新中文版v4.10.0.20
疯狂大酒店(Grand Hotel Mania)是一款好玩的