Skip to content

PHP API, Hooks & CLI

InterventionImage exposes module methods via $this->wire()->modules->get('InterventionImage'), attaches 15 hook methods to Pageimage and Page, and registers 2 processwire-console CLI commands.

Module Public Methods (ProcessWire\InterventionImage)

Section titled “Module Public Methods (ProcessWire\InterventionImage)”
Method Return / Purpose
manager() Returns the active Intervention\Image\ImageManager bound to the healthiest detected driver (vips, imagick, gd).
calculate(?int $width, ?int $height, string $aspectRatio = '', string $breakpoint = '') Computes array{width: int, height: int, maxWidth: int, ratio: float} from configured breakpoints and aspect ratios.
inspectQueue(?Page $page = null, int $limit = 50) Returns array{total: int, items: list<array{target: string, dimensions: string, source: string}>} for pending .queue files.
processQueue(?Page $page = null, int $limit = 50) Encodes pending .queue variations in batch (array{processed: int, failed: int, remaining: int, errors: list<string>}).
processQueueFile(string $queuePath) Processes a single .queue sidecar file directly.
clearVariations(?Page $page = null, array $options = []) Deletes variations and/or sidecars (variations, lqip, colors, hashes, queue, dryRun) and returns count + byte stats.
resolveTargetDirectory(Page $page) Returns the resolved site/assets/files/{id}/ directory for a page.
  • Sizing & Manipulation: $image->size(), $image->crop(), $image->contain(), $image->watermark().
  • Responsive Markup & LQIP: $image->render(), $image->attrs(), $image->srcset(), $image->lqip().
  • Visual Color Analysis: $image->dominantColor(), $image->palette(), $image->colorTheme().
  • Perceptual Hashing: $image->imageHash(), $image->hashDistance(), $image->isSimilar().
  • Page Cleanup: $page->clearImageVariations(array $options = []).

All 2 CLI Commands & Flags (vendor/bin/wire)

Section titled “All 2 CLI Commands & Flags (vendor/bin/wire)”

Inspects, processes, or clears delayed .queue image variations:

Terminal window
php vendor/bin/wire image:queue --status --page=1024 --json
php vendor/bin/wire image:queue --limit=50 --page=/fleet/ --json
php vendor/bin/wire image:queue --clear --force --json
Flag Description
--limit Maximum number of .queue variations to process or list in one run.
--page Limit operation to a specific ProcessWire page ID or path.
--status Inspect pending .queue variations without encoding them.
--clear Delete pending .queue descriptors without generating variations.
--force Skip confirmation prompt when using --clear in scripts or --json mode.
--json Emit structured JSON output.

Previews or deletes generated image variations and sidecar cache files:

Terminal window
php vendor/bin/wire image:clear --dry-run --json
php vendor/bin/wire image:clear --page=1024 --variations-only --force --json
php vendor/bin/wire image:clear --lqip-only --colors-only --hashes-only --queue-only --force --json
Flag Description
--page Limit cleanup to a single ProcessWire page ID or path.
--variations-only Clear only generated image variations (preserve sidecars).
--lqip-only Clear only .lqip.webp placeholder sidecars.
--colors-only Clear only .colors.json color extraction sidecars.
--hashes-only Clear only .hashes.json perceptual hash sidecars.
--queue-only Clear only pending .queue variation descriptors.
--dry-run Report matching files and bytes without deleting anything.
--force Execute deletion without interactive confirmation.
--json Emit structured JSON output.

Symptom: InterventionImage falls back to Imagick or GD even though libvips is installed on the host.

Fix: Verify ext-ffi is enabled (php -m | grep FFI), ffi.enable=true (or preload for CLI) is set in php.ini, and intervention/image-driver-vips is installed via Composer.

Delayed .queue Images Do Not Appear Until Reload

Section titled “Delayed .queue Images Do Not Appear Until Reload”

Symptom: Variations are queued as .queue files instead of being written immediately.

Fix: Run php vendor/bin/wire image:queue --limit=100 via cron or disable 'delayed' in Modules -> Configure -> InterventionImage -> options if you prefer synchronous encoding.

Next steps