按照composer扩展
composer require intervention/image
文档介绍:https://image.intervention.io/v2/introduction/installation
使用示例:
<?php
error_reporting(E_ALL &~ E_NOTICE);
require './vendor/autoload.php';
use Intervention\Image\ImageManagerStatic as Image;
// 处理图片大小尺寸
function check_img($dir,$file){
// open an image file
$img = Image::make($dir."/".$file);
// resize image instance
$img->resize(200, 200);
// insert a watermark
//$img->insert('public/watermark.png');
// save image in desired format
$img->save('./all2/'.$file);
}
$dir = "./all";
$files = scandir($dir);
foreach ($files as $key => $value) {
if (!in_array($value,['.','..'])) {
check_img($dir,$value);
}
}
echo "success";
?>
网友评论