To make a thumbnail of a JPEG image, use:
gm convert -size 120x120 cockatoo.jpg -resize 120x120 +profile "*" thumbnail.jpg
-size 参数说明
------------------------------------------
原文:
In this example, '-size 120x120' gives a hint to the JPEG decoder that the image is going to be downscaled to 120x120,
allowing it to run faster by avoiding returning full-resolution images to GraphicsMagick for the subsequent resizing operation.
The '-resize 120x120' specifies the desired dimensions of the output image.
It will be scaled so its largest dimension is 120 pixels.
The '+profile "*"' removes any ICM, EXIF, IPTC, or other profiles that might be present in the input and aren't needed in the thumbnail.
译文:
在这个例子中,'-size 120x120'给了JPEG解码器一个暗示,图像将会缩减到120x120,
允许它运行得更快通过避免返回GraphicsMagick全分辨率图像对后续的调整操作。
'-resize 120x120'指定理想的输出图像的尺寸。
这将是按比例缩小的所以它的最大尺寸是120像素。
'+profile "*"' 删除任何ICM,EXIF,IPTC或其他资料,可能会出现在输入和不需要的缩略图。
-size 效果测试
------------------------------------------
测试环境:
OS: MAC OS X 10.7
CPU:i5 2410(双核4线程)
GM:version 1.3.7 未使用多线程(默认安装未开启openMP)
大图片测试
-----------------------------------
gm identify a.jpg
a.jpg JPEG 3040x1824+0+0 DirectClass 8-bit 2.1M 0.000u 0:01
gm benchmark -iterations 100 -stepthreads 1 convert a.jpg -resize 100x100 +profile "*" a1.jpg (耗时466ms)
Results: 1 threads 100 iter 46.64s user 46.64s total 2.144 iter/s 2.144 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 100x100 a.jpg -resize 100x100 +profile "*" a2.jpg (耗时47ms)
Results: 1 threads 100 iter 4.72s user 4.71s total 21.231 iter/s 21.186 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert a.jpg -resize 500x500 +profile "*" a3.jpg (耗时532ms)
Results: 1 threads 100 iter 53.15s user 53.40s total 1.873 iter/s 1.881 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 500x500 a.jpg -resize 500x500 +profile "*" a4.jpg (耗时130ms)
Results: 1 threads 100 iter 13.06s user 13.06s total 7.657 iter/s 7.657 iter/cpu 1.00 speedup 1.000 karp-flatt
小图片测试
-----------------------------------
gm identify b.jpg
b.jpg JPEG 1024x768+0+0 DirectClass 8-bit 125.4K 0.000u 0:01
gm benchmark -iterations 100 -stepthreads 1 convert b.jpg -resize 100x100 +profile "*" b1.jpg (耗时68ms)
Results: 1 threads 100 iter 6.79s user 6.79s total 14.728 iter/s 14.728 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 100x100 b.jpg -resize 100x100 +profile "*" b2.jpg (耗时8.4ms)
Results: 1 threads 100 iter 0.83s user 0.84s total 119.048 iter/s 120.482 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert b.jpg -resize 500x500 +profile "*" b3.jpg (耗时102ms)
Results: 1 threads 100 iter 10.21s user 10.22s total 9.785 iter/s 9.794 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 500x500 b.jpg -resize 500x500 +profile "*" b4.jpg (耗时100ms)
Results: 1 threads 100 iter 10.24s user 10.26s total 9.747 iter/s 9.766 iter/cpu 1.00 speedup 1.000 karp-flatt
小图片测试
-----------------------------------
gm identify b.jpg
b.jpg JPEG 1024x768+0+0 DirectClass 8-bit 125.4K 0.000u 0:01
gm benchmark -iterations 100 -stepthreads 1 convert b.jpg -sample 100x100 +profile "*" s1.jpg (耗时16ms)
Results: 1 threads 100 iter 1.64s user 1.65s total 60.606 iter/s 60.976 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 100x100 b.jpg -sample 100x100 +profile "*" s2.jpg (耗时4.3ms)
Results: 1 threads 100 iter 0.43s user 1.51s total 66.225 iter/s 232.558 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert b.jpg -sample 500x500 +profile "*" s3.jpg (耗时26.5ms)
Results: 1 threads 100 iter 2.65s user 2.65s total 37.736 iter/s 37.736 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 500x500 b.jpg -sample 500x500 +profile "*" s4.jpg (耗时26.4ms)
Results: 1 threads 100 iter 2.64s user 2.64s total 37.879 iter/s 37.879 iter/cpu 1.00 speedup 1.000 karp-flatt
小图片测试
-----------------------------------
gm identify b.jpg
b.jpg JPEG 1024x768+0+0 DirectClass 8-bit 125.4K 0.000u 0:01
gm benchmark -iterations 100 -stepthreads 1 convert b.jpg -thumbnail 500x500 +profile "*" t1.jpg (耗时41ms)
Results: 1 threads 100 iter 4.11s user 4.22s total 23.697 iter/s 24.331 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 500x500 b.jpg -thumbnail 500x500 +profile "*" t2.jpg (耗时40ms)
Results: 1 threads 100 iter 4.06s user 4.06s total 24.631 iter/s 24.631 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert b.jpg -thumbnail 500x500 +profile "*" t3.jpg (耗时41ms)
Results: 1 threads 100 iter 4.12s user 4.13s total 24.213 iter/s 24.272 iter/cpu 1.00 speedup 1.000 karp-flatt
gm benchmark -iterations 100 -stepthreads 1 convert -size 500x500 b.jpg -thumbnail 500x500 +profile "*" t4.jpg (耗时40ms)
Results: 1 threads 100 iter 4.06s user 4.07s total 24.570 iter/s 24.631 iter/cpu 1.00 speedup 1.000 karp-flatt
总结
------------------------------------------
1、适用于生成小于300x300的小尺寸缩略图。
2、适用于原图与输出图片尺寸差距较的场景。
3、需要提前了解输入的原图的尺寸范围,应大于输出图片的尺寸。如果原图尺寸小于 -size width x height,反到无性能优化效果。
参考:http://www.graphicsmagick.org/convert.html
相关推荐
Nginx+Lua+GraphicsMagick实现动态生成指定尺寸的图片
现在,对一个Web程序员来说,图像处理已经属于必会知识之一了...且不说Flickr,Yupoo等专业图片分享网站,就算是一个和图片分享不沾边的网站,也会用到很多图片处理的功能,比如说:用户上传头像,然后自动生成缩略图。
缩略图OpenResty(Nginx)+Lua+GraphicsMagick
将图片的上传,分布式管理 交由seaweedfs管理,可提供更快的响应速度,更方便,无痛的分布式扩展节点,billion 级别的。后面使用openresty + lua-resty-weedfs + graphicsmagick 生成缩略图功能独立处理。
nginx-lua-GraphicsMagick网站中,需要根据需求,动态生成缩略图,网上找了些别人写好的脚本,也在github上找到了一些,自己稍微改写了下,让脚本同时支持00.jpg_80x80.jpg和00_80x80.jpg的2种格式。具体可以参考...
竖起大拇指Good thumbs 是 Node.js 的缩略图生成器工具,它试图比以前的解决方案做得更好。开始安装good-thumbs库。 $ npm install good-thumbs --save安装或 像这样实例化good-thumbs : var thumbs = require ( '...
使用GraphicsMagick处理图片 添加水印 合成图片 图片转换 图片处理
JDK自带的图片处理库,虽稳定简单,性能却比较差;ImageMagick是目前最流行的图片处理工具,它的功能非常丰富;GraphicsMagick的功能略逊于ImageMagick,但是它的效率更强悍,但大多数情况下,GM的功能已经足够使用...
GraphicsMagick能够动态的生成图片,特别适用于互联网的应用。可以用来处理调整尺寸、旋转、加亮、颜色调整、增加特效等方面。GaphicsMagick不仅支持命令行的模式,同时也支持C、C++、Perl、PHP、Tcl、 Ruby等的调用...
GraphicsMagick是图像处理技术,集成java demo,实现裁剪、合成等功能
GraphicsMagick用来处理图片的大小缩略。进行裁剪
GraphicsMagick 是一个用来读写、生成超过 90 种图像格式的工具集合,可以对图片进行格式参数处理,支持包括 TIFF, JPEG, JPEG-2000,PNG, PDF, PhotoCD, SVG, 和 GIF 等图像格式。GraphicsMagick 是基于 ImageMagick...
GraphicsMagick图片库GraphicsMagick-1.3.26.tar.xz Java图片处理 - 安装ImageMagick库使用convert命令 - 文章中的辅助文件 http://blog.csdn.net/chwshuang/article/details/64921665
关于使用Tengine+Lua+GraphicsMagick实现图片自动裁剪缩放的开发文档。
教你如何搭建一个图片切割和缩放的服务 1.搭建GraphicsMagick服务 2.配置nginx 3.修改Lua脚本 详情见文档
GraphicsMagick-1.3.18-Q8-win64 处理图像的专业工具
GraphicsMagick-1.3.40安装包,包含linux版本,windows32和windows64
GraphicsMagick for node.js 首先得安装 GraphicsMagick 或者 ImageMagick。然后调用
GraphicsMagick-1.3.33.tar.gz、GraphicsMagick-1.3.33-Q16-win64-dll.exe、 a.jpg