【发布时间】:2017-01-06 00:31:21
【问题描述】:
我有一个名为 wallpaperise.sh 的脚本,它获取一张图像并将其转换为相同的图像,只是这次分辨率为 16:9。
## Usage: ./wallpaperise.sh <imagename.jpg>
aw=16 #desired aspect ratio width...
ah=9 #and height
in="$1"
out="wallpaperised_$1"
wid=`convert "$in" -format "%[w]" info:`
hei=`convert "$in" -format "%[h]" info:`
tarar=`echo $aw/$ah | bc -l`
imgar=`convert "$in" -format "%[fx:w/h]" info:`
if (( $(bc <<< "$tarar > $imgar") ))
then
nhei=`echo $wid/$tarar | bc`
convert "$in" -gravity center -crop ${wid}x${nhei}+0+0 "$out"
elif (( $(bc <<< "$tarar < $imgar") ))
then
nwid=`echo $hei*$tarar | bc`
convert "$in" -gravity center -crop ${nwid}x${hei}+0+0 "$out"
else
cp "$in" "$out"
fi
问题在于它创建的图像(即使它根本没有改变图像)的文件大小比原始文件大?
我能做些什么来解决这个问题?
【问题讨论】:
标签: linux bash shell ubuntu wallpaper