现在写东西都喜欢封装成类.....大家调用一下就行了..我就不说怎么调用了
复制代码 代码如下:<?php
class resize_image{
private $o_img_width;//原图像宽度
private $o_img_height;//原图像高度
private $n_img_width;//新图像宽度
private $n_img_height;//新图像高度
private $o_img_file;//原图像文件
private $o_img_source;//原图像资源
private $n_img_file;//新图像资源
private $n_img_source;//新图像资源
private $o_to_n_per=0.5;//图像缩放比
//初始化内部变量
function __construct($oldfile,$newfile){
list($width,$height)=getimagesize($oldfile);
$this->o_img_file=$oldfile;
$this->o_img_width=$width;
$this->o_img_height=$height;
$this->n_img_file=$newfile;
}
//等比例缩放并且解决GIF透明色为黑色背景的问题
function get_resize_scaling_img(){
$this->n_img_width=$this->o_img_width*$this->o_to_n_per;
$this->n_img_height=$this->o_img_height*$this->o_to_n_per;
//等比例缩放图片(算法)
if ( $this->n_img_width && ( $this->o_img_width <$this->o_img_height))
{
$this->n_img_width = ( $this->n_img_height/$this->o_img_height) * $this->o_img_width;
}
else
{
$this->n_img_height = ($this->n_img_width / $this->o_img_width) * $this->o_img_height;
}
$this->o_img_source=imagecreatefromgif($this->o_img_file);
//创建一个等比例缩放大小的画布
$this->n_img_source=imagecreatetruecolor($this->o_img_width,$this->n_img_height);
//美化:去除黑色不透明背景
$trans_init=imagecolortransparent($this->o_img_source);
//寻找透明色并且判断是否在总颜色中
if($trans_init>=0 && $trans_init < imagecolorstotal($this->o_img_source)){
//如果在的话则搜索这个颜色的RGB色相
$trans_index=imagecolorsforindex($this->o_img_source,$trans_init);
//找到之后就创建这样一个颜色
$trans_new=imagecolorallocate($this->n_img_source,$trans_index["red"],$trans_index["green"],$trans_index["blue"]);
//然后我们用这个颜色去填充新的图像
imagefill($this->n_img_source,0,0,$trans_new);
//然后我们在把填充色设置为透明
imagecolortransparent($this->n_img_source,$trans_new);
}
//拷贝原图像到新画板上
imagecopyresized($this->n_img_source,$this->o_img_source,0,0,0,0,$this->n_img_width,$this->n_img_height,$this->o_img_width,$this->o_img_height);
return $this->n_img_source;
}
//最终销毁资源
function __destruct(){
imagedestroy($this->o_img_source);
imagedestroy($this->n_img_source);
}
}
说明:因为先前没想那么多所以声明了很多私有的内部变量以便调用...程序看起来很笨拙啊......
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】