ahp/thumbnail

用于视图中的图片即时缩略图生成器

dev-master 2019-05-01 12:29 UTC

This package is auto-updated.

Last update: 2024-09-29 05:42:16 UTC


README

PHP Thumbnail 是一个 PHP 图像处理 库,提供了一种更简单、更易于表达的方式来创建缩略图,以改善您网站的 SEO

它能做什么?

  • 裁剪图片
  • 调整图片大小
  • 适应图片
  • 更改图片质量
  • 更改图片的宽度和高度

入门

要求

  • PHP >=7.1
  • intervention/image ^2.4@dev

安装

composer require ahp/thumbnail

安装完成后,您就可以使用它了
// 通过辅助函数
img($path, $width, $height, $mode, $quality)
OR
// 通过类
\Thumb\Thumb::make($path, $width, $height, $mode, $quality)

之后缩略图将在给定路径的同一目录下创建,命名为 thumbnail

参数

  • path : 图片路径 string|required
  • width : 希望的宽度 int|null
  • height : 希望的高度 int|null
  • mode: 之一 fitresizecrop
  • quality : 图片质量 int|null = 100

示例

// Using img() helper function
<img src="<?= img($path, $width, $height, $mode, $quality) ?>">

// Full example
<img src="<?= img('files/animals/koala.jpg', 500, 200, 'crop', 50) ?>">

// we can ommit width or height but one of them is required to calculate it from other one
<img src="<?= img('files/animals/koala.jpg', 500) ?>">

// OR
<img src="<?= img('files/animals/koala.jpg', null, 200) ?>">

许可协议

PHP Thumbnail 采用 MIT 许可协议

版权所有 2019 Amirhossein Pooladvand