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

RSS 订阅当前论坛  

$5.95 Web Hosting     

上一主题 下一主题
 17  1/2  1  2  > 
     
标题: [问题] php 上传图片 压缩大小 怎么实现的?  
 
firstsmileman
注册会员
Rank: 2



UID 92688
精华 0
积分 90
帖子 94
金钱 90 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-5-8
状态 离线
[广告]: 代充Paypal帐号美元
php 上传图片 压缩大小 怎么实现的?

谢谢 ,本人现在特想知道这个问题!
2008-5-19 11:39 AM#1
查看资料  发短消息  顶部
 
喜悦村会计
注册会员
Rank: 2



UID 98556
精华 0
积分 116
帖子 190
金钱 116 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-9-14
状态 离线
[广告]: 代充Paypal帐号美元
你向灾区人民捐款100元,我告诉你怎么实现
2008-5-19 12:22 PM#2
查看资料  发短消息  顶部
 
firstsmileman
注册会员
Rank: 2



UID 92688
精华 0
积分 90
帖子 94
金钱 90 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-5-8
状态 离线
[推荐阅读] php配置选项可修改范围
靠  我都捐了
2008-5-19 12:54 PM#3
查看资料  发短消息  顶部
 
静水流深
新手上路
Rank: 1
初级会员



UID 66865
精华 0
积分 41
帖子 55
金钱 41 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2005-9-23
状态 离线
[推荐阅读] 北京低薪诚聘高级PHP开发经理,月薪6-8K
貌类要用到某种组件吧?
我也想知道!
期待高手!












JokeJoke
2008-5-19 01:08 PM#4
查看资料  发短消息  顶部
 
firstsmileman
注册会员
Rank: 2



UID 92688
精华 0
积分 90
帖子 94
金钱 90 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-5-8
状态 离线
[推荐阅读] 包子新游戏上线
期待高手指点
2008-5-19 01:14 PM#5
查看资料  发短消息  顶部
 
niohe (网缘伟伟)
论坛元老
Rank: 8Rank: 8
PHPOX


UID 73469
精华 0
积分 3133
帖子 569
金钱 3133 喜悦币
威望 0
人脉 0
阅读权限 90
注册 2006-5-16
来自 吉林延边
状态 离线
[推荐阅读] MYSQL4/5备分程序写法
gd2          



QQ:86958842,承接各种小型网站项目.我的BLOG http://www.aitao8.cn/
2008-5-19 01:16 PM#6
查看资料  访问主页  发短消息  QQ  顶部
 
firstsmileman
注册会员
Rank: 2



UID 92688
精华 0
积分 90
帖子 94
金钱 90 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-5-8
状态 离线
[推荐阅读] 今天,一次暴富的机会与我擦肩而过
时刻期待着高手指点
2008-5-19 01:24 PM#7
查看资料  发短消息  顶部
 
firstsmileman
注册会员
Rank: 2



UID 92688
精华 0
积分 90
帖子 94
金钱 90 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2007-5-8
状态 离线
[推荐阅读] PHP显示出错消息的三种方法
thanks  i got it
2008-5-19 02:23 PM#8
查看资料  发短消息  顶部
 
奶瓶 (NP博士)
版主
Rank: 7Rank: 7Rank: 7
老仙


UID 52707
精华 4
积分 5559
帖子 6230
金钱 5509 喜悦币
威望 50
人脉 0
阅读权限 100
注册 2004-11-22
来自 北大中文系
状态 离线
[推荐阅读] 菜鸟诚心求实习或者应聘PHPER
GD

<?php
/**
    * Method resize
    */
    
protected function _resize($new_width 0$new_height 0)
    {
        if (
$new_width <=&& $new_height <= 0)
        {
            
// Just copy it
            
@copy($this->source_filename$this->target_filename);
            return;
        }
        
        if (
$new_width <= 0)
        {
            
$new_width $new_height $this->rate;
        }
        
        if (
$new_height <= 0)
        {
            
$new_height $new_width $this->rate;
        }
        
        
$this->target_width $new_width;
        
$this->target_height $new_height;
        
        
$this->_prepare();
        
        
imagecopyresized($this->target_gd_obj$this->source_gd_obj0000$this->target_width$this->target_height$this->source_width$this->source_height);
        
        
$this->_save();
    }
?>
ImageMagick

<?php
/**
    * Method thumbnail
    * In new version of ImageMagick, this is just like resize, but it's more faster
    */
    
protected function _thumbnail($new_width 0$new_height 0)
    {
        
$this->target_width $new_width;
        
$this->target_height $new_height;

        
$option '-thumbnail';
        
$param $new_width 'x' $new_height;
        if (!
$new_width)
        {
            
$param 'x' $new_height;
        }

        if (!
$new_height)
        {
            
$param $new_width;
        }

        
$this->cmd $this->_gen_cmd($option$param);

        return 
$this->_exec_cmd();
    }

    
/**
    * Generate a command line to execute imagemagick command tool
    */
    
protected function _gen_cmd($option$param '')
    {
        
// Must source and target
        
if (!$this->source_filename || !$this->target_filename)
        {
            return 
false;
        }

        
// "convert" or "mogrify"
        
if ($this->source_filename == $this->target_filename)
        {
            
$this->handler $this->bin_mogrify;
            
$m_flag true;
        }

        else
        {
            
$this->handler $this->bin_convert;
            
$m_flag false;
        }

        
$cmd_exec true_path($this->bin_dir '/' $this->handler);
        
$cmd $cmd_exec . (!$m_flag ? (' ' $this->source_filename ' ') : ' ') . $option ' ' $param ' ' $this->target_filename;

        return 
$cmd;
    }

    
/**
    * Execute command
    */
    
private function _exec_cmd()
    {
        @
exec($this->cmd);
        if (
file_exists($this->target_filename))
        {
            return 
true;
        }

        return 
false;
    }
?>
MagickWand

<?php
/**
    * Method resize
    */
    
protected function _resize($new_width 0$new_height 0)
    {
        
$this->target_width $new_width;
        
$this->target_height $new_height;

        
$rv MagickReadImage($this->wand_obj$this->source_filename);
        if (!
$rv)
        {
            return 
false;
        }

        
$rv MagickResizeImage($this->wand_obj$new_width$new_heightMW_TriangleFilter1);
        if (!
$rv)
        {
            return 
false;
        }

        
$rv MagickWriteImage($this->wand_obj$this->target_filename);

        return 
$rv;
    }
?>
代码片段,剩下的自己看着办





图片包子,注册送100包子!
2008-5-19 03:12 PM#9
查看资料  访问主页  Blog  发短消息  QQ  ICQ 状态  Yahoo!  顶部
 
ctrlming
注册会员
Rank: 2



UID 118391
精华 0
积分 108
帖子 275
金钱 102 喜悦币
威望 0
人脉 6
阅读权限 20
注册 2008-4-9
来自 北京
状态 离线
[推荐阅读] js 跳转出的窗口中文显示乱码
搞点注释吧 真的有些看不懂。



我的目标是:灌到论坛发大水。
2008-5-19 04:22 PM#10
查看资料  Blog  发短消息  顶部
 17  1/2  1  2  > 
     


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


 




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

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