承接 maximal/php-webp-thumbnailer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maximal/php-webp-thumbnailer

Composer 安装命令:

composer require maximal/php-webp-thumbnailer

包简介

PHP (over Imagine) helper for creating and caching WebP thumbnails in real time

README 文档

README

WebpThumbnailer is a thumbnail helper which allows you to generate and cache image thumbnails in your PHP application on the fly.

Installation

Install this library with Composer:

php composer.phar require "maximal/php-webp-thumbnailer" "*"

or add

"maximal/php-webp-thumbnailer": "*"

to the require section of your app’s composer.json file.

Checking the environment

You will need WebP coder (cwebp command) installed in your system.

For instance in Ubuntu/Debian it is included in webp package:

sudo apt install webp

Check the command:

cwebp -version

You should get an output with version number (like 0.6.1).

If you have installed cwebp to a different command or path, configure the static property WebpThumbnailer::$cwebpCommand before using the helper (see the example below).

More info about WebP: https://developers.google.com/speed/webp/

Generating thumbnails

Use this thumbnailer in your PHP application:

use maximal\thumbnail\WebpThumbnailer;

echo WebpThumbnailer::picture('/path/to/img/image.png', $width, $height);

More options (outbound instead of default inset; alt and class attribute added):

use maximal\thumbnail\WebpThumbnailer;

echo WebpThumbnailer::picture(
	'/path/to/img/image.png',
	$width,
	$height,
	false,
	['alt' => 'Alt attribute', 'class' => 'img-responsive']
);

Custom cwebp command:

use maximal\thumbnail\WebpThumbnailer;

WebpThumbnailer::$cwebpCommand = '/usr/local/bin/cwebp';
echo WebpThumbnailer::picture('/path/to/img/image.jpg', $width, $height);

The helper’s picture() method uses modern <picture> HTML tag as follows:

<picture data-cache="hit|new">
	<source srcset="/assets/thumbnails/...image.png.webp" type="image/webp" />
	<img src="/assets/thumbnails/...image.png" other-attributes="" />
</picture>

Here you have image/webp source for browsers which support WebP images and traditional (PNG, JPEG, TIFF, GIF) image fallback.

Author

统计信息

  • 总下载量: 598
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固