despark/laravel-image-purify

Laravel 的 https://github.com/despark/image-purify 包装器

0.3 2020-03-20 11:11 UTC

This package is auto-updated.

Last update: 2024-09-20 20:46:48 UTC


README

本包是 despark/image-purify 的 Laravel 包装器

安装

从 composer 获取

composer require despark/laravel-image-purify

使用 Laravel 5.5 或更高版本时,该包将被自动发现。如果您使用的是旧版本的 Laravel,请在您的 config/app.php 文件中添加以下内容

$providers = [
    ...
    Despark\Laravel\ImagePurify\ImagePurifyServiceProvider::class,
]

如果您需要一个 purifier 实例,可以通过依赖注入 Despark\ImagePurify\Interfaces\ImagePurifierInterface

如果您想注册一个外观,请将以下内容添加到您的 config/app.php

$aliases = [
    ...
    'ImagePurify' => \Despark\Laravel\ImagePurify\Facades\ImagePurify::class
]

如果您需要自定义选项,可以通过以下方式发布配置

php artisan vendor:publish --provider "Despark\Laravel\ImagePurify\ImagePurifyServiceProvider" --tag config

示例用法

use Despark\ImagePurify\Interfaces\ImagePurifierInterface;

class HomeController extends Controller{
    
    public function optimize(ImagePurifierInterface $purifier){
        $purifier->purify('path/to/file');
    }
}

有关更多选项和使用方法,请参阅 despark/image-purify 文档。