linux下如果批量缩图?

OOo,TeX,KO,ABI,GIMP,Picasa,ProE,QCAD,Inkscape,Kicad,Eagle
回复
xain
帖子: 219
注册时间: 2007-02-05 18:55

linux下如果批量缩图?

#1

帖子 xain » 2007-02-26 18:06

怎样在linux下批量修改一个目录中所有图片的大小?
如将~/pics/ 目录下的所有图片 按正常比例缩小到宽640(高按原来比例计算).
vcc
帖子: 23
注册时间: 2007-02-23 23:43

#2

帖子 vcc » 2007-02-26 21:09

试试imagemagick
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#3

帖子 eexpress » 2007-02-27 0:18

convert -size 32这样的。都是imagemagick里面的小软件。高效率。安装了就有html帮助和实例。
● 鸣学
头像
Tenyears
帖子: 2245
注册时间: 2005-06-30 15:46
来自: 成都

#4

帖子 Tenyears » 2007-02-27 9:53

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

1. 制作索引图和动画

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

2. 缩放 convert -sample 80x40 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
Humanity to others // 己所不欲,勿施与人
Laptop: ThinkPad X220 --- Win7 Home / Ubuntu 12.04
Desktop: Win7/Ubuntu 12.04
Server: Ubuntu12.04
xain
帖子: 219
注册时间: 2007-02-05 18:55

#5

帖子 xain » 2007-02-28 19:29

谢谢各位,早就听说过Image MagicK 的大名了,看来要用用。
头像
Jimmy.Zhou
帖子: 475
注册时间: 2006-12-05 21:51
来自: Vienna, Austria

#6

帖子 Jimmy.Zhou » 2007-03-01 1:34

mark :D
Jimmy.Zhou

Acer Extensa 5620G
T5250 + HD 2400 XT + 2G DDR2 +160G SATA + iwp 3945
Ubuntu Intrepid Ibex + Firefox 3
头像
eagle5678
帖子: 1865
注册时间: 2006-07-08 14:07

#7

帖子 eagle5678 » 2007-03-24 14:20

看起来不错,试试
mkii
帖子: 50
注册时间: 2007-10-24 12:49

#8

帖子 mkii » 2007-11-03 13:19

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

1. 制作索引图和动画

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

2. 缩放 convert -sample 80x40 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
文件名中有空格就会出现稀奇古怪的错误
dbzhang800
帖子: 3182
注册时间: 2006-03-10 15:10
来自: xi'an China
联系:

#9

帖子 dbzhang800 » 2007-11-03 13:54

晕,你就不会给它们加上引号吗 :D
mkii
帖子: 50
注册时间: 2007-10-24 12:49

#10

帖子 mkii » 2007-11-03 14:24

如何批量加引号?
zhh01pfg
帖子: 66
注册时间: 2005-10-16 20:25

#11

帖子 zhh01pfg » 2007-11-05 13:51

楼上的兄弟,难道你不用通配符的么?
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#12

帖子 eexpress » 2007-11-05 14:01

for i in *.jpg; do convert """$i""" -scale 90 """${i%jpg}"""-90点宽度.jpg; done
● 鸣学
tomguy
帖子: 702
注册时间: 2005-09-27 10:32

#13

帖子 tomguy » 2007-11-05 14:44

ubuntu 中默认的图片浏览工具就可以完成你的任务。
mkii
帖子: 50
注册时间: 2007-10-24 12:49

#14

帖子 mkii » 2007-11-06 8:05

eexpress 写了:for i in *.jpg; do convert """$i""" -scale 90 """${i%jpg}"""-90点宽度.jpg; done
谢谢,学到东西了
回复