承接 starcitizentools/thumbro 相关项目开发

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

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

starcitizentools/thumbro

Composer 安装命令:

composer require starcitizentools/thumbro

包简介

Imrproves and expands thumbnails in MediaWiki.

README 文档

README

👍🖼️😎

Thumbro

Can we get Thumbor for the wiki?
We have Thumbor at home.
Thumbor at home:

Thumbro improves and expands thumbnail generation in MediaWiki. Instead of relying on a single tool, it automatically picks the most suitable image library for each file format — so every thumbnail comes out at the best quality and smallest size, with no manual tuning and room to add better libraries over time. Forked from Extension:VipsScaler.

Features

  • Routes each format to the best-suited image library automatically (currently libvips and libwebp), instead of MediaWiki's default ImageMagick and GD
  • Produces higher-quality, smaller thumbnails — including for animated images
  • Renders WebP thumbnails by default for GIF, JPEG, PNG, and WebP (including animated)
  • Lets you fine-tune encoding per format with custom load and save options
  • Extends thumbnail support to more formats, such as animated WebP
  • Adds a <source> element to images via the ThumbroBeforeProduceHtml hook
  • Adds a hidden anchor so web crawlers can reach the original-resolution image (T54647)

Installation

  1. Install the image libraries Thumbro uses. libvips is required; libwebp is recommended for crisp, compact animated-GIF thumbnails. On Debian-based systems:
apt-get install libvips-tools webp
  1. Download the extension and place the files in a directory called Thumbro in your extensions/ folder.
  2. Add the following to the bottom of your LocalSettings.php, after all other extensions:
wfLoadExtension( 'Thumbro' );
  1. ✔️ Done — visit Special:Version on your wiki to confirm the extension is installed.

Configuration

ℹ️ Thumbro works out of the box — no configuration required.

$wgThumbroLibraries

The image libraries Thumbro can run, keyed by library. Each library maps its binaries (by binary name) to their executable paths. libwebp ships two tools — gif2webp and cwebp — so it owns both.

Default:

$wgThumbroLibraries = [
	'libvips' => [ 'vipsthumbnail' => '/usr/bin/vipsthumbnail' ], // resize (+ vips-webp encode)
	'libwebp' => [
		'gif2webp' => '/usr/bin/gif2webp', // animated-GIF encode
		'cwebp'    => '/usr/bin/cwebp',     // static-WebP encode
	],
];

$wgThumbroOptions

Controls how each file type is thumbnailed as a resize → encode pipeline. The defaults are tuned per format, so most wikis never need to change this.

Each MIME block has:

Key Description
enabled Turn Thumbro on or off for this file type
minArea / maxArea Optional: only handle sources whose area (px²) is within range
resize The resize stage: { "options": { … } } — libvips load/resize options
encode An ordered list of encoder choices. Each entry is { "encoder", "when"?, "options" }. The first entry whose when capability guard the file satisfies is used; an entry with no when is the catch-all (put it last). Each encoder owns its own options.

Encoders: vips-webp (libvips webpsave — also handles animation), cwebp (libwebp, static only — more byte-efficient), gif2webp (libwebp, animated). when guards match the file's capabilities: animated, alpha (transparency), underThreshold (area ≤ $wgThumbroMaxAnimatedArea).

Default (abridged):

$wgThumbroOptions = [
	// Static WebP → cwebp (smaller); animated WebP → vips; vips catch-all if cwebp is absent.
	'image/webp' => [
		'enabled' => true,
		'resize'  => [ 'options' => [] ],
		'encode'  => [
			[ 'encoder' => 'vips-webp', 'when' => [ 'animated' => true ],
			  'options' => [ 'strip' => 'true', 'Q' => '90', 'smart_subsample' => 'true' ] ],
			[ 'encoder' => 'cwebp', 'options' => [ 'q' => '80', 'm' => '6' ] ],
			[ 'encoder' => 'vips-webp',
			  'options' => [ 'strip' => 'true', 'Q' => '90', 'smart_subsample' => 'true' ] ],
		],
	],
	'image/jpeg' => [
		'enabled' => true,
		'resize'  => [ 'options' => [] ],
		'encode'  => [ [ 'encoder' => 'vips-webp',
			'options' => [ 'strip' => 'true', 'Q' => '80', 'smart_subsample' => 'false', 'effort' => '6' ] ] ],
	],
	'image/png' => [
		'enabled' => true,
		'resize'  => [ 'options' => [] ],
		'encode'  => [ [ 'encoder' => 'vips-webp',
			'options' => [ 'near_lossless' => 'true', 'Q' => '60', 'strip' => 'true' ] ] ],
	],
	// GIF: transparent animation → gif2webp; opaque animation → vips animated; else vips first-frame.
	'image/gif' => [
		'enabled' => true,
		'resize'  => [ 'options' => [] ],
		'encode'  => [
			[ 'encoder' => 'gif2webp', 'when' => [ 'animated' => true, 'alpha' => true, 'underThreshold' => true ],
			  'options' => [ 'mixed' => '', 'q' => '80', 'm' => '4' ] ],
			[ 'encoder' => 'vips-webp', 'when' => [ 'animated' => true, 'underThreshold' => true ],
			  'options' => [ 'strip' => 'true', 'Q' => '90', 'smart_subsample' => 'true' ] ],
			[ 'encoder' => 'vips-webp',
			  'options' => [ 'strip' => 'true', 'Q' => '90', 'smart_subsample' => 'true' ] ],
		],
	],
];

Other options

Name Description Values Default
$wgThumbroMaxAnimatedArea Largest animation Thumbro will fully re-encode, measured as width × height × frames. Bigger animations are rendered as a single static frame to keep thumbnailing fast. integer 25000000
$wgThumbroEnabled Disable Thumbro across the wiki (the Special:ThumbroTest page still works) true / false true
$wgThumbroExposeTestPage Enable the Special:ThumbroTest comparison page true / false false
$wgThumbroTestExpiry Cache lifetime, in seconds, for images streamed to Special:ThumbroTest integer 3600

Comparing thumbnails

Thumbro ships a special page for comparing thumbnails before and after Thumbro. Enable it with:

// Enable the Special:ThumbroTest page
$wgThumbroExposeTestPage = true;

To keep the "before" thumbnail untouched by Thumbro, either disable Thumbro site-wide:

// Disable Thumbro site-wide
$wgThumbroEnabled = false;

…or disable the specific file format you want to test under $wgThumbroOptions.

Requirements

  • MediaWiki 1.43.0 or later
  • libvips (8.14 or later; older versions may work but are untested) — required. Drives core thumbnail generation via the vipsthumbnail command.
  • libwebp (the cwebp and gif2webp tools; Debian/Ubuntu webp package) — recommended. cwebp encodes static WebP thumbnails more compactly than libvips; gif2webp encodes animated GIFs to compact animated WebP, far smaller than libvips for transparent animations. Without it, both fall back to libvips automatically.
  • Imagick — optional. Powers the detailed comparison statistics on Special:ThumbroTest.

starcitizentools/thumbro 适用场景与选型建议

starcitizentools/thumbro 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 498 次下载、GitHub Stars 达 11, 最近一次更新时间为 2024 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 starcitizentools/thumbro 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 498
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

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