益友网(http://www.1uu2.com) 做linux用户的良师益友、linux操作系统命令教程

当前位置: 益友网 > Linux资讯 > 文章正文

Linux下用批量convert管理图片

发表于 2009-12-03 20:57 | 来源: | 阅读 770 次

把所有eps文件格式图片转化为jpg,文件名不变(覆盖):

mogrify -format jpg *.eps

见 http://203.208.37.132/search?q=cache:VRHsUJNuZ0gJ:linux.sheup.com/linux/39/linux27208.htm+linux+convert+%E6%89%B9%E9%87%8F%E5%A4%84%E7%90%86%E5%9B%BE%E5%83%8F+%E6%96%87%E4%BB%B6%E5%90%8D%E4%B8%AD%E6%9C%89%E7%A9%BA%E6%A0%BC&hl=zh-CN&client=firefox-a&gl=cn&st_usg=ALhdy28Q_D8thAhaXzTm2HCPfgmSgKu4fg&newwindow=1&strip=1

另外一篇文章备查:

http://203.208.37.132/search?q=cache:2Ub4SYBQVakJ:www.linuxbyte.org/linux-convert-mini-howto.html+linux+convert&hl=zh-CN&client=firefox-a&gl=cn&st_usg=ALhdy2-fdBdKv8wg564xRHxAsjTyE42mtw&newwindow=1&strip=1

具体方法如下:

sudo apt-get install imagemagick
创建一个 img.sh 文件,内容为

#/bin/sh
for img in `ls nini-pic/*`
do
mkdir sm-nini-pic
convert -rotate 270 -resize 30%x30% $img sm-$img
done

# sh img.sh (运行 img.sh)
这里nini-pic 是我原文件所在目录,sm-nini-pic新文件的存放目录。 convert -rotate 270 -resize 30%x30% 旋转270° 分辨率缩小为原来的30%。

下面是Ubuntu中文论坛找到的关于Image MagicK的一些资料

Image MagicK 是一个强大的图象处理工具包。它提供了几个非常方便的命令行命令: display, animate,import, montage,mogrify,identify等,可以进行图象的显示,缩放,旋转,调色,加框,加注释等,还能制作GIF动画,图象索引,能自动生成图象.

1. 制作索引图和动画

!/bin/bash
montage -bordercolor red -borderwidth 3 -label “%f” -tile 5×3 *.JPG montage.jpg
mogrify -format gif *.JPG
display montage.jpg
animate *.JPG

2. 缩放 convert -sample 80×40 input.jpg output.jpg #注意:缩放后图像保持原来的长宽比例 convert -sample 25%x25% input.jpg output.jpg
3. 为当前目录的所有图像生成缩略图

for img in `ls *.jpg`
do
convert -sample 25%x25% $img thumb-$img
done

4. 获取文件信息 libtiff

tiffinfo filename.tiff
pnginfo filename.png

5. 可以使用 ImageMagick 的 identify

identify -verbose sample.png
identify -format “%wx%h” sample.png

6. 旋转图像

convert -rotate 90 input.jpg output.jpg

7. 更改文件类型

convert input.jpg output.png

8. 为图像增加注释文字

convert -font helvetica -fill white -pointsize 36 \
-draw ‘text 10,50 “Floriade 2002, Canberra, Australia”‘ \
floriade.jpg comment.jpg
convert -font fonts/1900805.ttf -fill white -pointsize 36 \
-draw ‘text 10,475 “stillhq.com”‘ \
floriade.jpg stillhq.jpg

9. 特殊效果

convert -charcoal 2 input.jpg output.jpg #炭笔
convert -colorize 255 input.jpg output.jpg #着色 可以指定三种颜色 red/green/blue
convert -implode 4 input.jpg output.jpg #内爆效果
convert -solarize 42 input.jpg output.jpg #曝光,模拟胶片曝光
convert -spread 5 input.jpg output.jpg #随机移动,参数是位移大小

10. 一次执行多个操作

convert -sample 25%x25% -spread 4 -charcoal 4 input.jpg output.jpg

via:http://hi.baidu.com/lyricidyll/blog/item/9f556c4570809c88b3b7dc2d.html

关键字:
喜欢益友网的文章,那就通过 RSS Feed 功能订阅阅读吧!

我要评论

*

* 绝不会泄露



返回首页 | 关于我们 | 联系我们 | 广告合作 | 网站地图 | 友情链接 | 版权声明 |