Conversation
The `cwebp` shell fallback dates back to the initial 2021 commit, when
it guarded against Imagick builds without libwebp delegate support. The
`utopia-base` image now ships Imagick with webp support, so the Imagick
path succeeds and the catch block has effectively stopped firing.
Switch to the same native pattern used for jpg, png, gif, avif, and
heic: setImageCompressionQuality + setImageFormat('webp'), then let the
shared getImagesBlob/writeImages path handle output.
Add two tests: blob-return via output() (covers the empty-path branch)
and webp-input roundtrip (covers readImageBlob on webp source).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryRemoves the legacy Confidence Score: 5/5Safe to merge — change is minimal, well-scoped, and aligns with existing patterns. Only finding is a P2 style concern about an overly permissive format assertion in the new tests. No logic or correctness issues were found in the production code path. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: use native Imagick for WebP output ..." | Re-trigger Greptile |
| $probe->readImageBlob($blob); | ||
| $this->assertEquals(100, $probe->getImageWidth()); | ||
| $this->assertEquals(100, $probe->getImageHeight()); | ||
| $this->assertTrue(in_array($probe->getImageFormat(), ['PAM', 'WEBP'])); |
There was a problem hiding this comment.
Overly permissive format assertion
'PAM' (Netpbm Portable Arbitrary Map) is accepted alongside 'WEBP' as a valid output format. In test_webp_blob_output this is harmless since the RIFF/WEBP magic-byte assertions on lines 425–426 already confirm the bytes are real WebP. But the same loose assertion is repeated in test_webp_from_webp_input (line 450) where there is no magic-byte guard, so a file saved in PAM format would silently pass the whole test. If PAM is a known quirk of a specific Imagick build, a brief comment would clarify the intent; otherwise tightening the assertion to 'WEBP' alone would give stronger coverage.
Summary
cwebpshell fallback in the webp save path — originally added in the 2021 initial commit to guard against Imagick builds lacking libwebp, but theutopia-baseimage now ships Imagick with webp supportsetImageCompressionQuality+setImageFormat('webp'), then fall through to the sharedgetImagesBlob/writeImagesoutput pathTest plan
test_crop100x100_webp,test_crop100x100_webp_quality30)test_webp_blob_output— verifiesoutput('webp')returns bytes with RIFF/WEBP magic and correct dimensions (covers the blob-return branch)test_webp_from_webp_input— verifies webp → webp roundtrip (coversreadImageBlobon webp source)🤖 Generated with Claude Code