tck/zf2-imageresizer

Laminas 的图像缩放和操作模块

v3.0.2 2023-06-28 15:57 UTC

This package is auto-updated.

Last update: 2024-09-28 18:34:07 UTC


README

Latest Stable Version Build Status Scrutinizer Code Quality Code Coverage Total Downloads License

此 Laminas 模块一旦启用,可以通过 URL 进行图像缩放和操作。

要求

重要!版本说明

  • 版本 3.x:Laminas 已停止支持 Zend Framework 3。
  • 版本 2.x:Zend Framework 3 已停止支持 Zend Framework 2。
  • 版本 1.x:Zend Framework 2

安装

在您的 Laminas 项目中通过 composer 安装

$ composer require tck/zf2-imageresizer

安装后

  1. 在您的 application.config.php 文件中启用它。

    <?php
    return [
        'modules' => ]
            // ...
            'TckImageResizer',
        ],
        // ...
    ];
  2. 在 "public" 文件夹中创建 "processed" 文件夹。

使用方法

基本语法

公共文件夹中的所有文件

  • folder/filename.ext
  • processed/folder/filename.$command1,param1,param2$command2.ext

示例:创建缩略图和灰度图像

  • img/logo.jpg
  • processed/img/logo.$thumb,160,120$grayscale.jpg

视图辅助函数

Laminas 模板

<img alt="Example image" src="<?php echo $this->resize('img/logo.jpg')->thumb(200, 160)->grayscale(); ?>" />

渲染的 HTML

<img alt="Example image" src="/processed/img/logo.$thumb,200,160$grayscale.jpg" />

命令列表

  • thumb(width, height)
  • resize(width, height)
  • grayscale
  • negative
  • gamma(correction)
  • colorize(hexColor)
  • sharpen
  • blur(sigma = 1)
  • 404(text = 'Not found', backgroundColor = 'F8F8F8', color = '777777', width = null, height = null) 在视图辅助函数中:->x404(...) [text: url-safe base64] - \TckImageResizer\Util\UrlSafeBase64::encode($text)

可能的自定义命令 - 示例:添加水印(待文档说明)

目标 / 待办事项

  • 更多命令
  • 更多命令选项
  • 管理功能
  • 创建占位符