PHP5:图像缩小及格式转换CLASS
例子1:缩小图像后直接输出至浏览器
$obj = new ReSizeImage();
$obj->setSourceFile('win.png');
$obj->saveFile(false);
$obj->setWidth(250);
$obj->setHeight(250);
$obj->draw();
例子2:缩小图像后保存新图像文件为“new.png”
$obj = new ReSizeImage();
$obj->setSourceFile('win.png');
$obj->setDstFile('new.png');
$obj->setWidth(250);
$obj->setHeight(250);
$obj->draw();
例子3:缩小图像后保存新图像文件为“new.jpg”,并设置其quality值为“100”
$obj = new ReSizeImage();
$obj->setSourceFile('win.png');
$obj->setDstFile('new.jpg');
$obj->setWidth(250);
$obj->setHeight(250);
$obj->draw(100);
例子4:捕捉程序中的异常
try {
$obj = new ReSizeImage();
$obj->setSourceFile('no.png');
$obj->saveFile(false);
$obj->setWidth(250);
$obj->setHeight(250);
$obj->draw();
} catch (Exception $ex) {
echo $ex;
}
本文转摘自『IT学习者』http://www.itlearner.com/article/2007/3919.shtml
- 相关文章
