[script] Correctly calcul new image size

This commit is contained in:
Mathieu Maret 2011-01-12 16:38:14 +01:00
parent 177c92976a
commit beabe7e08f

View File

@ -39,18 +39,17 @@ function resize {
res=$(xdpyinfo | grep dimensions | awk '{print $2}') res=$(xdpyinfo | grep dimensions | awk '{print $2}')
tailleX=$(echo $res | awk -F "x" '{print $1}'); tailleX=$(echo $res | awk -F "x" '{print $1}');
tailleY=$(echo $res | awk -F "x" '{print $2}'); tailleY=$(echo $res | awk -F "x" '{print $2}');
echo "Screen Size is X: $tailleX, Y: $tailleY"
# Get image size # Get image size
res=$(identify -format '%w %h\n' $1) res=$(identify -format '%w %h\n' $1)
imgX=$(echo $res | awk '{print $1}') imgX=$(echo $res | awk '{print $1}')
imgY=$(echo $res | awk '{print $2}') imgY=$(echo $res | awk '{print $2}')
echo "Original Image Size is X: $imgX, Y: $imgY" echo "Original Image Size is X: $imgX, Y: $imgY"
# Calculate resize factor # Calculate resize factor
rapX=$(($tailleX*1000/$imgX))
rapY=$(($tailleY*1000/$imgY))
echo "Screen Size is X: $tailleX, Y: $tailleY"
mult=0 mult=0
div=0 div=0
if [ $rapX -gt $rapY ]; # If using $tailleX and $imgX as factor scale for Y -> use it! It will perfectly fitt for X and do the best for Y
if [ $tailleY -gt $((($tailleX*$imgY)/$imgX)) ];
then then
mult=$tailleX mult=$tailleX
div=$imgX div=$imgX
@ -100,7 +99,7 @@ fixdbus
if [[ -e /usr/bin/feh ]] if [[ -e /usr/bin/feh ]]
then then
feh --bg-center $todaywp DISPLAY=:0 feh --bg-center $todaywp
fi fi
if [[ -e /usr/bin/xfconf-query ]] if [[ -e /usr/bin/xfconf-query ]]
then then