php生成缩略图经典类_PHP教程
从国外网站找到的一款php生成缩略图代码,有需要的朋友可以参考一下。 代码如下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;
}
}
?>Usage
Save the above file as SimpleImage。
php and take a look at the following examples of how to use the script。The first example below will load a file named picture。
jpg resize it to 250 pixels wide and 400 pixels high and resave it as picture2。jpg代码如下load('picture。jpg');
$image->resize(250,400);
$image->save('picture2。
jpg');
?>If you want to resize to a specifed width but keep the dimensions ratio the same then the script can work out the required height for you, just use the resizeToWidth function代码如下load('picture。
jpg');
$image->resizeToWidth(250);
$image->save('picture2。jpg');
?>http://www。bkjia。com/PHPjc/632969。
htmlwww。bkjia。comtruehttp://www。bkjia。com/PHPjc/632969。htmlTechArticle从国外网站找到的一款php生成缩略图代码,有需要的朋友可以参考一下。 代码如下 ?php /* * File: SimpleImage。
php * Author: Simon Jarvis * C。
答:不是的!这跟你的设置有关系。 打开存放视频文件的文件夹——右键自定义文件夹——看图设置 点击扩大图片详情>>
答:详情>>
答:计算机网络发展主要是智能性和实用性.它发展的前景是随着社会的发展及人类的发展而发展,主要是提高人类发展的质量空间.相应的可以提高人的就业率.详情>>
答:这样,用户可以随身携带笔记本电脑在大楼之间或在房间之间移动当计算机与无线AP或其他计算机相距较远时,随着信号的减弱,或者传输速率明显下降,或者根本无法实现与AP...详情>>