承接 8ctopus/webp8 相关项目开发

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

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

8ctopus/webp8

Composer 安装命令:

composer require 8ctopus/webp8

包简介

command line tool to convert images to webp

README 文档

README

license lines of code

webp8 is a command line tool to convert images to webp format

how to install

You have the choice between:

  • composer install composer require 8ctopus/webp8
  • download the phar
  • or build it yourself
curl -LO https://github.com/8ctopus/webp8/releases/download/1.2.0/webp8.phar

# check hash against the one published under releases
sha256sum webp8.phar

# make phar executable
chmod +x webp8.phar

# rename phar (from here on optional)
mv webp8.phar webp8

# move phar to /usr/local/bin/ (optional)
mv webp8 /usr/local/bin/

Windows only

  • download and extract cwebp.exe from libwebp
  • add cwebp.exe to PATH (sysdm.cpl -> Advanced -> Environment Variables)
  • download webp8
curl -LO https://github.com/8ctopus/webp8/releases/download/1.2.0/webp8.phar
  • check hash against the one published under releases

convert images to webp

./webp8 convert [--cwebp_m] [-cwebp_q] [--cwebp_z] [--multithreading] directory

[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 15843/15843 (100%) -   1 hr/1 hr   - 6.0 MiB

[OK]

------- ----------- --------- ------------- ------- --------------- -----------
 total   converted   skipped   webp bigger   time    size original   size webp
------- ----------- --------- ------------- ------- --------------- -----------
 15843   15843       0         235           64:20   1.2 GB          150.3 MB
------- ----------- --------- ------------- ------- --------------- -----------

NOTE: converted images that are bigger in webp format are automatically deleted since the whole point is to get smaller images. You can see the bigger images in the webp bigger column.

delete existing webp images

./webp8 cleanup [--dry-run] [-v] directory

htaccess code to show webp instead of png/jpg when browser supports

Code adapted from webp-express

RewriteEngine On

# redirect images to webp when possible
# check if browser accepts webp
RewriteCond %{HTTP_ACCEPT} image/webp

# check if requested file is jpg or png
RewriteCond %{REQUEST_FILENAME} \.(jpe?g|png)$

# check if webp for image exists
RewriteCond %{REQUEST_FILENAME}\.webp -f

# serve webp image instead
RewriteRule . %{REQUEST_FILENAME}\.webp [T=image/webp,E=EXISTING:1,E=ADDVARY:1,L]

# make sure that browsers which do not support webp also get the Vary:Accept header
# when requesting images that would be redirected to existing webp on browsers that does.
SetEnvIf Request_URI "\.(jpe?g|png)$" ADDVARY

# Apache appends "REDIRECT_" in front of the environment variables defined in mod_rewrite, but LiteSpeed does not.
# So, the next lines are for Apache, in order to set environment variables without "REDIRECT_"
SetEnvIf REDIRECT_EXISTING 1 EXISTING=1
SetEnvIf REDIRECT_ADDVARY 1 ADDVARY=1

# Set Vary:Accept header for the image types handled by WebP Express.
# The purpose is to make proxies and CDNs aware that the response varies with the Accept header.
Header append "Vary" "Accept" env=ADDVARY

for development

build bin

  • bump version
  • run ./build.sh

debug code

php src/EntryPoint.php convert -- images

# cleanup test dir
git clean -xfd images

improvement ideas

8ctopus/webp8 适用场景与选型建议

8ctopus/webp8 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Webp」 「cwebp」 「image conversion」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 8ctopus/webp8 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 8ctopus/webp8 我们能提供哪些服务?
定制开发 / 二次开发

基于 8ctopus/webp8 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-28