承接 sitegeist/image-jack 相关项目开发

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

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

sitegeist/image-jack

Composer 安装命令:

composer require sitegeist/image-jack

包简介

Jack of all trades concerning image optimization. Also introduces the usage of next-gen-image-formats

README 文档

README

Jack of all trades concerning image optimization. Also introduces the usage of next-gen-image-formats.

What does it do?

Adds the possibility to optimize existing jpg, gif and png files during processing. Furthermore, it can add a webP copy of every processed image.

Installation

Use composer to add the extension:

composer require "sitegeist/image-jack"
  • Completely clear all processed images via the maintenance module
  • Flush Caches
  • Change the server configuration (see below) or activate the fallback driver xclass

Configuration

Webserver

To deliver the webP images, the webserver needs to be configured properly. Example for Apache (.htaccess):

RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.*)\.(png|gif|jpe?g)$
RewriteCond %{REQUEST_FILENAME}\.webp -f
RewriteRule ^ %{REQUEST_FILENAME}\.webp [L,T=image/webp]

<IfModule mod_headers.c>
    <FilesMatch "\.(png|gif|jpe?g)$">
        Header append Vary Accept
    </FilesMatch>
</IfModule>

As we are creating the webP images as copies (keeping the original image untouched) this configuration delivers the webP image if the client supports it. Otherwise, the original image is served.

Storage API (beta)

As a fallback solution (e.g. for remote storages) there is an option in the extension settings to activate a xclass for the storage driver. There needs to be a class for every storage driver that should be extended. The LocalDriver and the AmazonS3Driver are already available. To avoid the cache problem (first client defines the served image format) the image formats from the clients accept header are added to the page cache identifier. If this option is activated the htaccess modification (see Webserver) is no longer necessary.

Scheduler / Cronjob

To start the image processing a command is available:

jack:process --limit=20

The images are processed one by one. By changing the limit, the number of images to process in one run can be defined.

Requirements

webp

For the webp conversion an installed version of Imagemagick or GraphicsMagick with webp support is required.

You can check this with:

gm -version | grep -i webp

or:

convert -version | grep -i webp

When using gd, webP support is needed.

jpg optimization

For optimizing jpg files the binary "jpegoptim" is required. You can check this with:

which jpegoptim

(Should return a path)

If missing it can be installed for example with this command:

apt install jpegoptim

png/gif optimization

For optimizing png and gif files the binary "optipng" is required. You can check this with:

which optipng

(Should return a path)

If missing it can be installed for example with this command:

apt install optipng

Extension settings

General

useLiveProcessing

If enabled the images are processed live on request using a LocalImageProcessor. This can lead to high load and very long loading times upon first request (depending on the number of images on the page). It is recommended to stick with the default and use the available command for processing.

useFallbackDriver (beta)

When enabled a xclass is used to extend the getPublicUrl function from the LocalDriver and AmazonS3Driver. This can be used if the htaccess solution is not working, e.g. for remote storages. See Storage API (beta) for more details.

WebP

active

(De)activate the conversion.

converter

Which way should be used to convert the images: Imagemagick/GraphicsMagick, GD or an external binary

options

Depending on the conversion type this field can be used for different purposes:

  • IM/GM: Add options that are directly passed to the binary
  • GD: Quality for the new images (1 - 100)
  • External: The complete path to the binary to be used. You can use %s for source and target image.

Avif

active

(De)activate the conversion.

converter

Which way should be used to convert the images: Imagemagick/GraphicsMagick, GD or an external binary

options

Depending on the conversion type this field can be used for different purposes:

  • IM/GM: Add options that are directly passed to the binary
  • GD: Quality for the new images (1 - 100)
  • External: The complete path to the binary to be used. You can use %s for source and target image.

Jpeg

active

(De)activate the optimization.

path

The path to the jpegoptim binary. Please use the complete path as is_executable won't work correctly otherwise.

Png

active

(De)activate the optimization.

path

The path to the optipng binary. Please use the complete path as is_executable won't work correctly otherwise.

Logging

Just activate the levels that should be written to the log file.

Custom optimizer/converter templates

The custom template should extend AbstractTemplate and implement TemplateInterface. Just use one of the existing templates as a starting point.

Custom templates can be registered like this:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['image_jack']['templates']['myCustomTemplate'] = \Vendor\Extension\Templates\CustomTemplate::class;

Jack will automatically pick up and run the new template if it is available for the given image type.

Troubleshooting

A log is written to var/log/typo3_image_jack_*.log

The extension settings offer the possibility to decide how verbose the logging should be.

Special thanks

This extension was inspired by the webp extension from plan2net.

Authors & Sponsors

The development and the public-releases of this package is generously sponsored by our employer https://sitegeist.de.

sitegeist/image-jack 适用场景与选型建议

sitegeist/image-jack 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81.68k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2022 年 11 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 sitegeist/image-jack 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 81.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2022-11-04