国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

PHP簡單生成縮略圖相冊的方法

2024-04-25 20:40:13
字體:
來源:轉載
供稿:網友

本文實例講述了PHP簡單生成縮略圖相冊的方法。分享給大家供大家參考。具體如下:

<?php

/*

* written by mot

* 根目錄下自己新建image thumb目錄

* */

class thumb{

private $src;

private $source;

private $s_width;

private $s_height;

private $dest;

private $d_height;

private $d_width;

private $name;

public function thumb($image_path,$rate = 0.5){

$this->src = $image_path;

$this->source = imagecreatefromjpeg($image_path);

$s_size = getimagesize($image_path);

$this->s_height = $s_size[1];

$this->s_width = $s_size[0];

$this->d_height = 100;

$this->d_width = 100;

$this->dest = imagecreate($this->d_width, $this->d_height);

$this->name = explode('.jpg', $image_path);

$this->name = $this->name[0];

}

public function make(){

imagecopyresized($this->dest, $this->source, 0, 0, 0, 0, $this->d_width, $this->d_height,

$this->s_width, $this->s_height);

$thumb = str_replace('image', 'thumb', $this->name.'-thumb.jpg');

imagejpeg($this->dest,$thumb,100);

$img = $thumb;

echo "<a href=$this->src><img src=$img></a>";

}

}

$hl = opendir(".//image//");

while(false != $file = readdir($hl)){

if($file == '.' || $file == '..') continue;

$path = './/image//'.$file;

$tmp = new thumb($path,0.3);

$tmp->make();

}

希望本文所述對大家的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 加查县| 东安县| 石嘴山市| 如东县| 十堰市| 汉中市| 大田县| 文水县| 宜君县| 长岛县| 大埔区| 乐陵市| 彭泽县| 蒙阴县| 明水县| 大埔县| 修水县| 安溪县| 集安市| 北川| 比如县| 尼勒克县| 汉源县| 肥西县| 三亚市| 兴隆县| 河南省| 贵德县| 仙游县| 玛纳斯县| 胶州市| 洱源县| 临沂市| 进贤县| 泌阳县| 奉贤区| 新龙县| 承德县| 五台县| 汶上县| 福海县|