php_imagick超强的PHP图片处理扩展
2016-02-13 16:43
726 查看
php_imagick是一个可以供PHP调用ImageMagick功能的PHP扩展,使用这个扩展可以使PHP具备和ImageMagick相同的功能。
ImageMagick是一套功能强大、稳定而且免费的工具集和开发包,可以用来读、写和处理超过185种基本格式 的图片文件,包括流行的TIFF, JPEG, GIF, PNG, PDF以及PhotoCD等格式。利用ImageMagick,你可以根据web应用程序的需要动态生成图片, 还可以对一个(或一组)图片进行改变大小、旋转、锐化、减色或增加特效等操作,并将操作的结果以相同格式或其它格式保存。
php_imagick程序示例
1.创建一个缩略图并显示出来
2.创建一个目录下的缩略图,并保存
3.缩略GIF动画图片
ImageMagick是一套功能强大、稳定而且免费的工具集和开发包,可以用来读、写和处理超过185种基本格式 的图片文件,包括流行的TIFF, JPEG, GIF, PNG, PDF以及PhotoCD等格式。利用ImageMagick,你可以根据web应用程序的需要动态生成图片, 还可以对一个(或一组)图片进行改变大小、旋转、锐化、减色或增加特效等操作,并将操作的结果以相同格式或其它格式保存。
php_imagick程序示例
1.创建一个缩略图并显示出来
1 2 3 4 5 6 7 | <?php header('Content-type: image/jpeg'); $image = new Imagick('image.jpg'); // If 0 is provided as a width or height parameter,// aspect ratio is maintained $image->thumbnailImage(100, 0); echo $image; ?> |
1 2 3 4 5 6 7 8 | <?php $images = new Imagick(glob('images/*.JPG')); foreach($images as $image) { // Providing 0 forces thumbnailImage to maintain aspect ratio $image->thumbnailImage(1024,0); } $images->writeImages(); ?> |
1 2 3 4 5 6 7 8 9 10 11 12 | <?php /* Create a new imagick object and read in GIF */ $im = new Imagick("example.gif"); /* Resize all frames */ foreach ($im as $frame) { /* 50x50 frames */ $frame->thumbnailImage(50, 50); /* Set the virtual canvas to correct size */ $frame->setImagePage(50, 50, 0, 0); }/* Notice writeImages instead of writeImage */ $im->writeImages("example_small.gif", true); ?> |
相关文章推荐
- php+uploadprogress实现上传进度功能
- PHP-CPP 安装
- php-fpm服务启动脚本
- php-fpm进程管理方式(static和dynamic)
- Phpmyadmin-3.4.8 安装配置
- ThinkPHP - 关联模型 - 多对多
- php编译添加扩展
- PHP处理服务器session问题导致的高负载
- php session 写入数据库
- PHP 首页导航栏源代码
- vsftp 安装 配置
- yii2从零开始一,安装
- phpstorm 常用设置
- 53个要点提高PHP编程效率
- PHP操作Mysql疑问?
- php等比例缩放图片及剪切图片代码分享
- php等比例缩放图片及剪切图片代码分享
- php session 写入数据库
- php判断邮箱地址是否存在的方法
- PHP常用设计模式之委托设计模式