Closed (fixed)
Project:
Crop or Fill
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Feb 2026 at 08:58 UTC
Updated:
11 Mar 2026 at 13:05 UTC
Jump to comment: Most recent
Comments
Comment #3
mably commentedSummary of changes
New files
src/Plugin/ImageToolkit/Operation/PillarboxTrait.php— Shared trait witharguments()andvalidateArguments()for the pillarbox toolkit operation.src/Plugin/ImageToolkit/Operation/gd/Pillarbox.php— GD toolkit operation: creates a colored canvas viacreate_new, fills with background color usingimagecolorallocate/imagefill, then pastes the original image withimagecopy.src/Plugin/ImageToolkit/Operation/imagemagick/Pillarbox.php— ImageMagick toolkit operation: uses-background,-gravity none, and-extentto achieve the same result in a single IM command.Modified files
src/Plugin/ImageEffect/CropOrFillEffect.php— Major refactoring:getCropTypeRatio()utility that loads the crop type and validates its aspect ratio in one place. Logs an error when the crop type has no ratio configured (misconfiguration). Returns parsed[width, height]orNULL.applyEffect()andtransformDimensions()check the ratio immediately at the top — free-form crop types (no ratio) or missing crop types delegate to parent for a standard crop.resolveTargetDimensions()now takes a parsed ratio array instead of aCropTypeentity. Always returns dimensions (never NULL) since the ratio is pre-validated.computeCanvasDimensions()shared byapplyPillarbox()andtransformDimensions().isOppositeOrientation()toisSameOrientation()(positive logic).$image->apply('pillarbox', [...])which is toolkit-agnostic.config/schema/crop_or_fill.schema.yml— Changedbgcolortype fromstringtocolor_hex(validatable core type).README.md— Updated to reflect ImageMagick support. Removed GD-only note.Tests
tests/src/Kernel/CropOrFillEffectTest.php— Rewritten with three crop types (landscape 3:2, portrait 2:3, square 1:1) and matching image styles:testSameOrientationCrops— portrait ratio on portrait image → standard crop with pixel verification.testOppositeOrientationFills— landscape ratio on portrait image → pillarbox 540×360 with red background corners.testSquareRatioDoesNotFill— square ratio on portrait image → standard crop (100×100).testTransformDimensionsSameOrientation— portrait ratio predicts crop dimensions.testTransformDimensionsOppositeOrientation— landscape ratio predicts canvas 540×360.testCropTypeRatioIsAlwaysUsed— 0×0 crop entity and no crop entity both produce pillarbox from crop type ratio.All 6 tests pass (25 assertions).
Comment #5
mably commented