system("/bin/bash /app/www/getimgsize.sh $save_dir $filename|tee -a /tmp/resizeimg.log");
[root@web_pre cron]# cat ./app/yuleit/lib/getimgsize.sh
#!/bin/bash
path=$1
echo "path=>"$path
img=$2
echo "img=>"$img
ext=${img##*.}
#echo $ext
imgsize=`find $path -name $img |xargs identify|awk '{print $7}'`
#echo $imgsize
if [[ $imgsize == *KB* ]]
then
var=${imgsize/KB/}
var=${var%.*}
fi
if [[ $imgsize == *MB* ]]
then
imgsize=${imgsize/MB/}
var=`echo "$imgsize*1000"|bc`
var=${var%.*}
fi
echo "size=>"$var
if [ $var -gt 200 ]
then
echo "bigpic"
imgwidth=`find $path -name $img |xargs identify|awk '{print $3}'|cut -d 'x' -f 1`
echo "width=>"$imgwidth
if [ $imgwidth -gt 800 ]
then
echo "resize"
convert -resize '800x600' $path/$img $path/$img
convert $path/$img -interlace Plane $path/$img
else
if [ "$ext" != "png" ];then
echo "quality"
convert -quality 80 $path/$img $path/$img
else
pngquant $path/$img --quality 80 --out $path/$img
fi
convert $path/$img -interlace Plane $path/$img
fi
else
convert $path/$img -interlace Plane $path/$img
fi
echo "==============================================================================="
system("/bin/bash /app/www/imgresize.sh $imgname 210x140");
system("/bin/bash /app/www/imgresize.sh $imgname 90x60");
[root@web_pre cron]# cat ./app/yuleit/lib/imgresize.sh
img=$1
echo "img=>"$img
size=$2
ext=${img##*.}
echo $ext
filename=${img##*/}
path=${img%/*}
if [ "$size" == "210x140" ];then
newimg=$path/X210X140_$filename
echo $newimg
convert -quality 100 -resize 210 $img $newimg
convert -quality 100 $newimg -gravity center -crop 210x140+0+0 $newimg
if [ "$ext" == "gif" ];then
convert $newimg -trim +repage $newimg
fi
size=`identify -format "%wx%h" $newimg`
if [ "$size" == "210x140" ];then
echo "ok"
else
echo "no"
convert -quality 100 -resize x210 $img $newimg
convert -quality 100 $newimg -gravity center -crop 210x140+0+0 $newimg
if [ "$ext" == "gif" ];then
convert $newimg -trim +repage $newimg
fi
fi
else
newimg=$path/X90X60_$filename
convert -quality 100 -resize 90 $img $newimg
convert -quality 100 $newimg -gravity center -crop 90x60+0+0 $newimg
if [ "$ext" == "gif" ];then
convert $newimg -trim +repage $newimg
fi
size=`identify -format "%wx%h" $newimg`
if [ "$size" == "90x60" ];then
echo "ok"
else
echo "no"
convert -quality 100 -resize x90 $img $newimg
convert -quality 100 $newimg -gravity center -crop 90x60+0+0 $newimg
if [ "$ext" == "gif" ];then
convert $newimg -trim +repage $newimg
fi
fi
fi