manujoz/images

用于将图片上传到服务器的类

2.0.0 2023-05-13 18:47 UTC

This package is auto-updated.

Last update: 2024-09-13 21:27:41 UTC


README

Images 是一个类,可以以简单且完全可配置的方式将图片上传到服务器

安装

$ composer require manujoz/images

使用

index.php

<?php

use Manujoz\Images\Images;

require( "vendor/autoload.php" );

$IMGS = new Images();
$response = $IMGS->copy( $_FILES[ "img" ], "/img/path/folder" );

echo $response[ "copy" ] . "<br>";
echo $response[ "dest" ] . "<br>";
echo $response[ "name" ] . "<br>";
echo $response[ "ext" ] . "<br>";
echo $response[ "path" ];

?>

文档

copy() 方法

使用 of() 方法进行翻译,此方法接受两个参数

$IMGS->copy( $file, $path, $name = null, $width = null, $height = null, $cover = true, $bigResize = false, $quality = "good" );

$file

要上传到服务器的文件对象

$path

保存图片的绝对路径

$name

目标图片文件名

$width

图片目标宽度

$heigh

图片目标高度

$cover

裁剪调整大小后的图片,使其完全覆盖指定的宽度和高度

$bigResize

强制将图片调整大小为更大的尺寸,默认情况下它只会调整大小为更小的尺寸。

$quality

我们想要的图片质量(max | good | medium | low)

$response

包含保存图片数据的数组

$response[ "copy" ]: Boolean

指示图片是否已复制

$response[ "dest" ]: String.

图片目标路径

$response[ "ext" ]: String.

目标图片扩展名

$response[ "name" ]: String.

目标图片名称

$response[ "path" ]: String.

图片目标绝对路径