您的位置:首页 > 其它

convert in ImageMagick resize by percent

2013-04-09 10:44 495 查看
#!/bin/bash

image="/media/C/1.jpg"
result="/media/C/12.jpg"
width=`convert $image -format "%w" info:`
height=`convert $image -format "%h" info:`

#Now convert your percentages to pixels as variables, for example

xoff=`convert xc: -format "%[fx:$width*10/100]" info:`
yoff=`convert xc: -format "%[fx:$height*10/100]" info:`
ww=`convert xc: -format "%[fx:$width*40/100]" info:`
hh=`convert xc: -format "%[fx:$height*40/100]" info:`

#then put that into your crop

convert $image -crop ${ww}x${hh}+${xoff}+${yoff} +repage $result
echo 'done'


above is crop, ref to : http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=17441

the following is resize by percentage:

ref to : http://www.imagemagick.org/Usage/resize/#percent

convert dragon.gif    -resize 50%  half_dragon.gif
convert terminal.gif  -resize 50%  half_terminal.gif


such simple ,but i have done it in hard way to finish this percentage resize task..... :-(
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: