Fix aspect ratio handling for gravity crops#45
Conversation
Greptile SummaryThis PR fixes a two-part bug in the non-center gravity crop path: it replaces an incorrect raw pixel-dimension comparison (
Confidence Score: 5/5The change is a targeted, well-reasoned fix to the non-center gravity resize path with comprehensive test coverage; safe to merge. Both changes in Image.php are mathematically correct: switching from raw pixel comparison to aspect-ratio comparison ensures the right dimension is pinned, and replacing $width * $originalAspect with ceil($width / $originalAspect) fixes the formula that previously under-calculated resizeHeight for portrait sources. The new tests exercise all nine gravity constants across both overflow directions with pixel-level color assertions. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: preserve aspect ratio for gravity c..." | Re-trigger Greptile |
Summary
Testing
./vendor/bin/phpunit --filter gravity(28 tests, 145 assertions)composer lintcomposer checkcomposer testreaches 51 tests; 3 existing AVIF/HEIC output tests fail locally because the installed ImageMagick delegates cannot encode HEIC and reject the AVIF lossless parameters