Imagick::thumbnailImage用法-生成缩略图

原图尺寸width:276px,height:110px

google

1
2
3
4
5
6
7
8
< ?php
/* 读取原图 */
$im = new imagick( "google.gif" );
/* 创建缩图 */
$im->cropThumbnailImage( 552, 220 );
/* 写文件 */
$im->writeImage( "552.22o.gif" );
?>

修改后的尺寸width:552px;height:220px;

demophp

1
2
3
4
5
6
7
8
< ?php
/* 读取原图 */
$im = new imagick( "google.gif" );
/* 创建缩图 */
$im->cropThumbnailImage( 276, 220 );
/* 写文件 */
$im->writeImage( "276.220.gif" );
?>

demophp1

作用:还是生成缩略图,有点不同,举个例子,我要生成一个固定276px*220px的图片,但等比缩略之后是276px*110px,或者是 552px*220px,这个时候用这个方法,可以切出:276px*220px,下按照最大缩放比例512*220,然后从图片中点截取276*220. 嗯,不知道能不能看懂?一般生成正方形或者固定长宽缩略图的时候用这个方法!

 

Tags:

Comments: 2

Leave a reply »

 
  • 怎么只切了后面几个字母,把前面给扔了

     
     
     
  • 写的不错,以后经常过来看看!一起加油!

     
     
     
  • Leave a Reply
     
    Your gravatar
    Your Name
     
     
     
     
     
 
About This Website

Lamp development & SEO & Plan of Website & Project Managment

Learn more »
Follow Us (SNS)
Help & Support

more about Bruce.xu»

Get in touch

QQ: +252339382
Email: shjuto @ gmail.com

Online contact form »