netbus 发表于 2010-9-16 22:18:32

网上找开源类 一堆。。。。。。。。。

smartweb 发表于 2011-3-8 07:48:19

$size = GetImageSize($paths.'/'.$realname);
if ( $size >800)               
      $config['width'] = 800;//(必须)设置你想要得图像宽度。   
if ( $size >800)
      $config['height'] = 800;//(必须)设置你想要得图像高度

smartweb 发表于 2011-3-8 07:49:31

$this->load->library('image_lib');
$config['image_library'] = 'gd2';//(必须)设置图像库   
      $config['source_image'] = $paths.'/'.$realname;//(必须)设置原始图像的名字/路径   
      $config['dynamic_output'] = FALSE;//决定新图像的生成是要写入硬盘还是动态的存在   
      $config['quality'] = '100%';//设置图像的品质。品质越高,图像文件越大   
      $config['new_image'] =$paths.'/'.$realname;//设置图像的目标名/路径。   
$size = GetImageSize($paths.'/'.$realname);
if ( $size >800)               
      $config['width'] = 800;//(必须)设置你想要得图像宽度。   
if ( $size >800)
      $config['height'] = 800;//(必须)设置你想要得图像高度


      $config['create_thumb'] = TRUE;//让图像处理函数产生一个预览图像(将_thumb插入文件扩展名之前)   
      $config['thumb_marker'] = '';//指定预览图像的标示。它将在被插入文件扩展名之前。例如,mypic.jpg 将会变成 mypic_thumb.jpg   
      $config['maintain_ratio'] = TRUE;//维持比例   
      $config['master_dim'] = 'auto';//auto, width, height 指定主轴线   
      $this->image_lib->initialize($config);   
      if (!$this->image_lib->resize())   
      {   
            echo $this->image_lib->display_errors();   
      }else{   
            //echo "成功的";   
      }

xjwinging 发表于 2011-4-15 17:42:05

建议用imagemagick处理。
http://www.imagemagick.org/Usage/

thenbsp 发表于 2012-1-12 11:27:01

PHP 显然可以做到,不过我觉得楼主的意思好像有点问题,一般来说,图片一般只会缩略为不超过指定宽高的大小,这样图片宽高比例不变,如果使用背景色填充,那么图片的宽高比例是会变的,我没有明白这样做有什么意义。
页: 1 [2]
查看完整版本: 图片处理类,能否按比例缩放