php实现图片的操作,也就是裁切,跟加水印
<?
class image {
protected $img;
protected $types = array(
1 => 'gif',
2 => 'jpg',
3 => 'png',
6 => 'bmp'
);
public function __construct($img=''){
!$img && $this->param($img);
}
public function param($img){
$this->img = $img;
return $this;
}
public function getImageInfo($img){
$info = @getimagesize($img);
if(isset($this->types[$info[2]])){
$info['ext'] = $info['type'] = $this->types[$info[2]];
} else{
$info['ext'] = $info['type'] = 'jpg';
}
$info['type'] == 'jpg' && $info['type'] = 'jpeg';
$info['size'] = @filesize($img);
return $info;
}
public function thumb($filename,$new_w=160,$new_h=120,$cut=0,$big=0){
$info = $this->getImageInfo($this->img);
if(!empty($info[0])) {
$old_w = $info[0];
$old_h = $info[1];
$type = $info['type'];
$ext = $info['ext'];
相关新闻>>
- 发表评论
-
- 最新评论 更多>>