Repository navigation
fix(image): keep derived crop sides at least one pixel - #14828
Conversation
When only one side is given, crop() derives the other from the source aspect ratio and rounds down. A 1px side on a skewed source derived 0, which then divided by zero for non-center gravity and reached Imagick as an empty geometry otherwise, so the storage preview answered 500. The derived side is now clamped to 1.
|
Review complete. No issues found — approved ✅. This PR introduces a gravity-based crop transformation (top/center/bottom variants) in the image package, wired into the storage preview pipeline with Imagick and GD support.
Reviewed commit: c310aa5 |
🟢 Tier S · Ready to merge
Updated
📂 Walkthrough · 3
Reviewed |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
…imension fix(image): keep derived crop sides at least one pixel (cherry picked from commit b2a765f)
Summary
When only one side is passed,
Utopia\Image\Image::crop()derives the other from the source aspect ratio and rounds down. A 1px side on a skewed source (for examplewidth=1, height=0on a landscape image) derived 0: with non-center gravity that divided by zero, otherwise Imagick got an empty geometry. The storage preview endpoint answered 500 for those params.The derived side is now clamped to at least 1px, and the "both sides 0" case is checked first so it still falls back to the source size. The preview endpoint returns a valid image for these params.
Test plan
bin/monorepo check imageandbin/monorepo test image; new data-provider test covers landscape and portrait sources with 1px sides across gravities (three cases throwDivisionByZeroErrorwithout the fix)testFilePreviewOnePixelSideWithGravity: preview of a landscape JPEG withwidth=1, height=0, gravity=top-leftreturns 200 and a 1x1 PNGRelated: appwrite-labs/cloud#5938