wangta69 / php-thumbnail
缩略图
1.1.0
2023-06-09 03:06 UTC
Requires
- php: >=5.3.0
- wangta69/file: ^1.0
This package is auto-updated.
Last update: 2024-09-14 04:43:55 UTC
README
安装
composer require wangta69/php-thumbnail
composer require "wangta69/php-thumbnail @dev"
如何使用
将远程图像保存到本地
use Pondol\Image\GetHttpImage;
$img_url = 'http://www.shop-wiz.com/myphoto.jpg';
$save_path = '/home/photos';
$image = new GetHttpImage();
$image->read($img_url)->save($save_path);
read(source image url)
=== 从URL读取图像;
set_size(width, height)
=== 创建空白图像
copyimage()
=== 从中心裁剪源图像复制到目标图像
copyWithRatio()
=== 将源图像复制到目标图像
save(destinaition image url)
=== 保存或创建图像
format(image format)
=== 改变图像格式
name('image name')
=== 改变图像名称,图像名称不应包含扩展名,扩展名将根据图像格式创建
将远程图像保存到本地(从中心裁剪源图像进行图像缩放)
use Pondol\Image\GetHttpImage;
$img_url = 'http://www.shop-wiz.com/myphoto.jpg';
$save_path = '/home/photos';
$image = new GetHttpImage();
$image->read($img_url)->->set_size(100, 100)->copyimage()->save($save_path);
将远程图像保存到本地(保持源比例进行图像缩放)
use Pondol\Image\GetHttpImage;
$img_url = 'http://www.shop-wiz.com/myphoto.jpg';
$save_path = '/home/photos';
$image = new GetHttpImage();
$image->read($img_url)->->set_size(100, 100)->copyWithRatio()->save($save_path);
将远程图像保存到本地(保持比例并更改文件格式)
use Pondol\Image\GetHttpImage;
$img_url = 'http://www.shop-wiz.com/myphoto.jpg';
$save_path = '/home/photos';
$image = new GetHttpImage();
$image->read($img_url)->set_size(100, 100)->copyWithRatio()->format('png')->save($save_path);
将远程图像保存到本地(更改文件名)
use Pondol\Image\GetHttpImage;
$img_url = 'http://www.shop-wiz.com/myphoto.jpg';
$save_path = '/home/photos';
$image = new GetHttpImage();
$image->read($img_url)->set_size(100, 100)->copyWithRatio()->name('myphoto')->save($save_path);
or
$image->read($img_url)->set_size(100, 100)->copyWithRatio()->name('myphoto')->format('png')->save($save_path);