I have the following script named wallpaperise.sh that takes an image and converts it to the the same own only this time with 16:9 resolution.
## 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
The problem is that the image it creates ( even if it doesn't change the image at all ) is of a bigger file size than the original?
What can I do to fix that?