-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image->resize(250,400);
- $image->save('picture2.jpg');?>
-
复制代码
2,设定宽度,等比例缩放
-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image->resizeToWidth(250);
- $image->save('picture2.jpg');?>
-
复制代码
3,设定高度,等比例缩放
-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image->resizeToHeight(500);
- $image->save('picture2.jpg');
- $image->resizeToHeight(200);
- $image->save('picture3.jpg');?>
-
复制代码
4,按比例,缩放至50%
-
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image->scale(50);
- $image->save('picture2.jpg');?>
-
复制代码
5,缩放后直接输出到屏幕
-
- header('Content-Type: image/jpeg');
- include('SimpleImage.php');
- $image = new SimpleImage();
- $image->load('picture.jpg');
- $image->resizeToWidth(150);
- $image->output();?>
复制代码
说明:
SimpleImage.php
请在本文开头提供的下载链接中取得。
>>> 您可能感兴趣的文章:
php等比例缩放图片的示例参考
php等比例缩放图片的工具SimpleImage实例学习
php批量缩放图片的代码举例
|