国产探花免费观看_亚洲丰满少妇自慰呻吟_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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荃湾区| 彰化县| 新疆| 宣恩县| 镇巴县| 罗源县| 忻州市| 余庆县| 迁西县| 浙江省| 闸北区| 双峰县| 桃源县| 雷波县| 前郭尔| 靖远县| 南投县| 全州县| 靖安县| 阿鲁科尔沁旗| 台江县| 德惠市| 彭州市| 勃利县| 黎平县| 铜川市| 离岛区| 桐庐县| 嘉荫县| 句容市| 乌海市| 林甸县| 墨脱县| 九龙坡区| 班玛县| 桦川县| 依兰县| 新化县| 崇左市| 垣曲县| 合作市|