<?php
system("/bin/bash /app/www/cron/lib/getimgsize.sh $save_dir $filename|tee -a /tmp/resizeimg.log");
?>
cat 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 "==============================================================================="