php中如何把文件夹里的前几个图片缩略图拷贝到一个文件夹图片上,显示出来
如何判断出是文件夹,然后在读取文件夹里被的图片文件,如果有的话就读取出来并获取它的缩略图,并且把它拷贝到一个文件夹图片中...
如何判断出是文件夹,然后在读取文件夹里被的图片文件,如果有的话就读取出来并获取它的缩略图,并且把它拷贝到一个文件夹图片中
展开
展开全部
if(!file_exists($_SERVER['DOCUMENT_ROOT']."/att/".date("ymd")))
{
if(mkdir($_SERVER['DOCUMENT_ROOT']."/att/".date("ymd"), 0777)) //创建名为mydir的目录
{
//print("目录创建成功"); //目录建立成功
}
}
$img=new C_SMAILLIMAGE;
$thumb=$img->resize_image($url,106,106,$_SERVER['DOCUMENT_ROOT']."/att/".date("ymd")."/".date("ymdhis")."_re1d.com_",$mode = 1);
return substr($thumb,strpos($thumb, 'att')-1);
//-----------------
下面是缩图类
class C_SMAILLIMAGE
{
var $src = ''; //原图片地址
var $dst = ''; //目标图片标示
var $mode = 1; //是否显示(0显示,1不显示)
var $exe = ''; // ps:upload/s_
function resize_image($src,$dst_width,$dst_height,$exe='',$mode = 0)
{
$width = $this->get_msg($src,0);
$height = $this->get_msg($src,1);
if ($width<=$dst_width&&$height<=$dst_height)
{
$imgname=getImage($src);
return $_SERVER['DOCUMENT_ROOT'].'/att/'.substr(getImage($imgname),0,6).'/'.$imgname;//当长宽在范围内。。不做处理。。。
}
else
{
$this->exe = $exe;
$this->mode = $mode;
$src_h = $this->get_msg($src,2);//return:resouse 返回图象标示符
$size = $this->resize($src,$dst_width,$dst_height);
$dst = @imagecreatetruecolor($size[x],$size[y]);
$bool = @imagecopyresampled($dst,$src_h,0,0,0,0,$size[x],$size[y],$width,$height);
$new_file = $this->exe.basename($src);
if($bool)
{
switch ($this->get_msg($src,3))
{
case 1:
imagegif($dst,$new_file);
break;
case 2:
imagejpeg($dst,$new_file);
break;
case 3:
imagepng($dst,$new_file);
break;
}
return $new_file;
}
else
{
return 0;//失败返回
}
/* }*/
}
}
{
if(mkdir($_SERVER['DOCUMENT_ROOT']."/att/".date("ymd"), 0777)) //创建名为mydir的目录
{
//print("目录创建成功"); //目录建立成功
}
}
$img=new C_SMAILLIMAGE;
$thumb=$img->resize_image($url,106,106,$_SERVER['DOCUMENT_ROOT']."/att/".date("ymd")."/".date("ymdhis")."_re1d.com_",$mode = 1);
return substr($thumb,strpos($thumb, 'att')-1);
//-----------------
下面是缩图类
class C_SMAILLIMAGE
{
var $src = ''; //原图片地址
var $dst = ''; //目标图片标示
var $mode = 1; //是否显示(0显示,1不显示)
var $exe = ''; // ps:upload/s_
function resize_image($src,$dst_width,$dst_height,$exe='',$mode = 0)
{
$width = $this->get_msg($src,0);
$height = $this->get_msg($src,1);
if ($width<=$dst_width&&$height<=$dst_height)
{
$imgname=getImage($src);
return $_SERVER['DOCUMENT_ROOT'].'/att/'.substr(getImage($imgname),0,6).'/'.$imgname;//当长宽在范围内。。不做处理。。。
}
else
{
$this->exe = $exe;
$this->mode = $mode;
$src_h = $this->get_msg($src,2);//return:resouse 返回图象标示符
$size = $this->resize($src,$dst_width,$dst_height);
$dst = @imagecreatetruecolor($size[x],$size[y]);
$bool = @imagecopyresampled($dst,$src_h,0,0,0,0,$size[x],$size[y],$width,$height);
$new_file = $this->exe.basename($src);
if($bool)
{
switch ($this->get_msg($src,3))
{
case 1:
imagegif($dst,$new_file);
break;
case 2:
imagejpeg($dst,$new_file);
break;
case 3:
imagepng($dst,$new_file);
break;
}
return $new_file;
}
else
{
return 0;//失败返回
}
/* }*/
}
}
参考资料: www.re1d.com
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询