Files
h4b-image-optim/h4b-image-optim.php
Henk 0e56ca6e63 fix: eliminate AVIF/WebP grey halo on white backgrounds (v0.2.3)
Diagnosed visible faint grey rectangle around B&W ink art images on
pages with pure-white backgrounds. Root cause was format encoder
luminance shift in near-white pixels:

  Source JPG corner: (253,253,253) = #FDFDFD = 99.2% white
  AVIF q=65 (default): (250,250,250) = #FAFAFA = 98.0% (1.2% halo)
  WebP q=80 (default): (249,249,249) = #F9F9F9 = 97.6% (1.6% halo)

Two changes:

1. avifenc now uses -y 444 (full chroma subsampling) instead of
   default 4:2:0. Brings AVIF corner to #FBFBFB = 98.4%, smaller
   file size as a bonus (~10% reduction on a typical art image).

2. WebP default quality raised 80 → 90. Reaches #FDFDFD = exact
   match with source JPG. File size increases ~30% but eliminates
   the halo entirely for WebP-capable browsers (vast majority).

AVIF still has 0.4% residual halo (libavif 0.11.1 ceiling at this
quality range — pushing higher yields no improvement, only file
size). Acceptable tradeoff: WebP is the served-by-default fallback
when AVIF isn't perfect.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 15:31:53 +10:00

29 lines
975 B
PHP

<?php
/**
* Plugin Name: H4B Image Optim
* Plugin URI: https://gitea.help4bis.com/help4bis/h4b-image-optim
* Description: ICC-safe image optimisation with WebP + AVIF generation. Replaces Smush Pro without the grey-wash bug. No CDN.
* Version: 0.2.3
* Author: help4bis (Henk + Claude)
* Author URI: https://help4bis.com
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Requires PHP: 8.1
* Requires at least: 6.4
* Text Domain: h4b-image-optim
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'H4B_IMG_OPTIM_VERSION', '0.2.3' );
define( 'H4B_IMG_OPTIM_FILE', __FILE__ );
define( 'H4B_IMG_OPTIM_DIR', plugin_dir_path( __FILE__ ) );
define( 'H4B_IMG_OPTIM_URL', plugin_dir_url( __FILE__ ) );
define( 'H4B_IMG_OPTIM_SLUG', 'h4b-image-optim' );
require_once H4B_IMG_OPTIM_DIR . 'includes/class-plugin.php';
H4B\ImageOptim\Plugin::instance()->boot();