喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: [问题] 遍历目录 并把大图片转换成自定义大小的图片  
 
justinyun
新手上路
Rank: 1



UID 93544
精华 0
积分 10
帖子 4
金钱 10 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-5-24
状态 离线
遍历目录 并把大图片转换成自定义大小的图片

请问有没有现成的,来学习下,或者告知,本人PHP菜鸟,谢谢
2007-6-11 09:21 PM#1
查看资料  发短消息  顶部
 
yanglei1979 (高老庄二庄主)
高级会员
Rank: 4
天蓬元帅


UID 73676
精华 0
积分 763
帖子 752
金钱 763 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2006-5-19
来自 深圳
状态 在线
[推荐阅读] 有经验的哥哥姐姐指条明路
用一段截图的程序就可以实现,很简单的,找找吧



今霄酒醒何处?杨柳岸,晓风残月。
2007-6-12 02:05 AM#2
查看资料  访问主页  发短消息  QQ . .   Yahoo!  顶部
 
jxxysong (jxxysong)
高级会员
Rank: 4
高级会员



UID 12761
精华 0
积分 902
帖子 910
金钱 902 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-2-10
状态 离线
[推荐阅读] 问个很简单的问题。
循环部分

<?php
$showData
=$objDataSet->getDataById($ids->field[0]['co_id'],"co_id",$in['module']);

        
$pics $Files->fileList($this->picurl.$showData['picpath']);

        for (
$i=0$i<count($pics); $i++)
        {
            if (!
preg_match("/^(less_)/ies",$pics[$i]['name']))
            {
                 if (!
is_file(dirname($pics[$i]['path'])."/less_".$pics[$i]['name']))
                 {
                     
$less_image->resizeimage($pics[$i]['path'],dirname($pics[$i]['path'])."/less_".$pics[$i]['name'],160,120,1);
                 }

                 
$thispics[$i]['bigname']  = $showData['picpath']."/".$pics[$i]['name'];
                 
$thispics[$i]['lessname'] = $showData['picpath']."/less_".$pics[$i]['name'];
            }
        }
?>
2007-6-12 08:57 AM#3
查看资料  访问主页  发短消息  QQ . .   顶部
 
jxxysong (jxxysong)
高级会员
Rank: 4
高级会员



UID 12761
精华 0
积分 902
帖子 910
金钱 902 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-2-10
状态 离线
[推荐阅读] 请问村子里人脉的功能怎么实现的
图片相关内库:

<?php
/*
图像相关
*/

if(!defined("__CLASS_IMAGE__"))
{
    
define("__CLASS_IMAGE__",1);

    require(
dirname(__FILE__)."/PhpClass.inc.php");


    class 
Image extends PhpClass
    
{
        
//图片类型
        
var $type;
        
//实际宽度
        
var $width;
        
//实际高度
        
var $height;
        
//改变后的宽度
        
var $resize_width;
        
//改变后的高度
        
var $resize_height;
        
//是否裁图
        
var $cut;
        
//源图象
        
var $srcimg;
        
//目标图象地址
        
var $dstimg;
        
//临时创建的图象
        
var $im;


        function 
Image()
        {
            
$this->PhpClass();
        }


        function 
resizeimage($img$img2$wid$hei,$c)
        {
                
$this->srcimg $img;
                
$this->dstimg $img2;
                
$this->resize_width $wid;
                
$this->resize_height $hei;
                
$this->cut $c;
                
//图片的类型
                
$this->type substr(strrchr($this->srcimg,"."),1);
                
//初始化图象
                
$this->initi_img();
                
//--
                
$this->width imagesx($this->im);
                
$this->height imagesy($this->im);
                
//生成图象
                
$this->newimg();
                
ImageDestroy ($this->im);
        }

        function 
newimg()
        {
                
//改变后的图象的比例
                
$resize_ratio = ($this->resize_width)/($this->resize_height);
                
//实际图象的比例
                
$ratio = ($this->width)/($this->height);
                if((
$this->cut)=="1")
                
//裁图
                
{
                        if(
$ratio>=$resize_ratio)
                        
//高度优先
                        
{
                                
$newimg imagecreatetruecolor($this->resize_width,$this->resize_height);
                                
imagecopyresampled($newimg$this->im0000$this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height);
                                
ImageJpeg ($newimg,$this->dstimg,99);
                        }
                        if(
$ratio<$resize_ratio)
                        
//宽度优先
                        
{
                                
$newimg imagecreatetruecolor($this->resize_width,$this->resize_height);
                                
imagecopyresampled($newimg$this->im0000$this->resize_width$this->resize_height$this->width, (($this->width)/$resize_ratio));
                                
ImageJpeg ($newimg,$this->dstimg,99);
                        }
                }
                else
                
//不裁图
                
{
                        if(
$ratio>=$resize_ratio)
                        {
                                
$newimg imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio);
                                
imagecopyresampled($newimg$this->im0000$this->resize_width, ($this->resize_width)/$ratio$this->width$this->height);
                                
ImageJpeg ($newimg,$this->dstimg,99);
                        }
                        if(
$ratio<$resize_ratio)
                        {
                                
$newimg imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height);
                                
imagecopyresampled($newimg$this->im0000, ($this->resize_height)*$ratio$this->resize_height$this->width$this->height);
                                
ImageJpeg ($newimg,$this->dstimg,99);
                        }
                }
        }
        
//初始化图象
        
function initi_img()
        {
                if(
$this->type=="jpg")
                {
                        
$this->im imagecreatefromjpeg($this->srcimg);
                }
                if(
$this->type=="gif")
                {
                        
$this->im imagecreatefromgif($this->srcimg);
                }
                if(
$this->type=="png")
                {
                        
$this->im imagecreatefrompng($this->srcimg);
                }
        }
    } 
//end class

}//end if defined

?>
2007-6-12 08:57 AM#4
查看资料  访问主页  发短消息  QQ . .   顶部
 
游戏人间
版主
Rank: 7Rank: 7Rank: 7
☞风云山庄大少爷☜


UID 62639
精华 2
积分 14665
帖子 7766
金钱 14515 喜悦币
威望 20
人脉 130
阅读权限 100
注册 2004-12-21
来自 广西人在北京
状态 离线
[推荐阅读] 求书...


QUOTE:
原帖由 jxxysong 于 2007-6-12 08:57 发表
内裤:

<?php
/*
图像相关
*/

if(!defined("__CLASS_IMAGE__"))
{
    define("__CLASS_IMAGE__",1);

    require(dirname(__FILE__)."/PhpClass.inc.php");

...




 
群号:6025396/6025252/19520091(广西PHP交流/PHP高级编程/算法交流) 寧可在嘗試中失敗,也不在保守中成功! 不為失敗找理由,只為成功找方法! 饿踢Blog
 
2007-6-12 08:58 AM#5
查看资料  访问主页  Blog  发短消息  顶部
 
jxxysong (jxxysong)
高级会员
Rank: 4
高级会员



UID 12761
精华 0
积分 902
帖子 910
金钱 902 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-2-10
状态 离线
[推荐阅读] 【招聘】PHP图书兼职作者
文件操作相关内库

<?php
/*
             文件列表
             $path当前路径
             $listChildDirs 是否列了子文件夹的内容
             $onlyDir 是否只列出文件夹
             $showPre 是否列出详细属性
             $order 排序方式
         */
        
function fileList($path='',$listChildDirs=false,$onlyDir=false,$showPre=false,$order="name")
        {
            if (empty(
$path)){
                if (isset(
$_SESSION['currPath']))$path $_SESSION['currPath'];
                else {
                    
$path $this->root."/";
                    
$_SESSION['currPath'] = $path;
                }
            }
            
$path $this->formatPath($path);
            if (
is_file($path)) $path dirname($path);
            else if (!
is_dir($path))return $this->err->catchErr($this->getSysMsg(1003,$path));
            
$this->affectFiles=0;
            
$this->affectDirs=0;
            
$this->listData=array();
            
$this->_fileList($path,0,$listChildDirs,$onlyDir,$showPre);
            return 
$this->getListData($order);
        }
?>
2007-6-12 09:00 AM#6
查看资料  访问主页  发短消息  QQ . .   顶部
 
jxxysong (jxxysong)
高级会员
Rank: 4
高级会员



UID 12761
精华 0
积分 902
帖子 910
金钱 902 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-2-10
状态 离线
[推荐阅读] 上海招聘PHP高级工程师月薪:3000-6000
楼上的,咋了?
2007-6-12 09:01 AM#7
查看资料  访问主页  发短消息  QQ . .   顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.053120 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP