美文网首页
Intervention Image php 图片处理

Intervention Image php 图片处理

作者: Mracale | 来源:发表于2022-04-26 13:56 被阅读0次

    按照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";
    
    ?>
    

    相关文章

      网友评论

          本文标题:Intervention Image php 图片处理

          本文链接:https://www.haomeiwen.com/subject/dagcyrtx.html