示例#1
0
        $dheight = (int) $dinfo['height'] * $calc;
        $paddingx = (int) ($width - $dwidth) / 2;
        $paddingy = (int) ($height - $dheight) / 2;
        imagecopyresampled($tim, $dim, $paddingx, $paddingy, 0, 0, $dwidth, $dheight, $dinfo['width'], $dinfo['height']);
        // 保存图片
        if (!$save) {
            $save = $dst;
            unlink($dst);
        }
        $createfunc = 'image' . $dinfo['ext'];
        $createfunc($tim, $save);
        imagedestroy($dim);
        imagedestroy($tim);
        return true;
    }
}
/*
echo '<pre>';
print_r(ImageTools::imageInfo('./fly.jpg'));
echo '</pre>';
*/
/*
echo ImageTools::water('./motox.jpg', './fly.png', './temp/test01.jpg', 0)?'Ok':'Faild';
echo ImageTools::water('./motox.jpg', './fly.png', './temp/test02.jpg', 1)?'Ok':'Faild';
echo ImageTools::water('./motox.jpg', './fly.png', './temp/test03.jpg', 2)?'Ok':'Faild';
echo ImageTools::water('./motox.jpg', './fly.png', './temp/test04.jpg', 3)?'Ok':'Faild';
*/
echo ImageTools::thumb('./motox.jpg', './temp/motox_thumb1.jpg', 200, 200) ? 'OK' : 'Faild';
echo ImageTools::thumb('./motox.jpg', './temp/motox_thumb2.jpg', 200, 300) ? 'OK' : 'Faild';
echo ImageTools::thumb('./motox.jpg', './temp/motox_thumb3.jpg', 300, 200) ? 'OK' : 'Faild';
echo '<h3>程序运行结束!</h3>';