Repository navigation
chore: absorb image into packages/image - #13867
Conversation
extracting image library
Feat new functionalities
…-issue fix-image-border-with-radius-issue
Co-authored-by: Eldad A. Fux <[email protected]>
CROP with optional Gravity
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…essionQuality setImageCompressionQuality() is silently ignored by the libheif coder in the Imagick PHP extension — quality had no effect and all output was encoded at the default level regardless of the requested value. The fix is to call setCompressionQuality() (object-level) after setImageFormat(), which correctly passes quality through to libheif. See: Imagick/imagick#711 Also updates the HEIC q100 expected file size in tests (8426 → 8490) to reflect the minor encoding difference between native Imagick and the old magick convert path at the same quality level. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fix: use native Imagick for AVIF and HEIC output instead of magick convert
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) <[email protected]>
fix: use native Imagick for WebP output
Fix aspect ratio handling for gravity crops
GIF already coalesced before resize; animated WebP took the static path and scaled delta frames independently, causing blocky ghosting. Use the same coalesce/deconstruct path for any multi-frame image. Co-authored-by: Cursor <[email protected]>
deconstructImages() can collapse identical pause frames into empty deltas that WebP encoding drops, zeroing playback delay. Keep coalesced frames and assert total delay is preserved. Co-authored-by: Cursor <[email protected]>
Fix animated WebP crop artifacts
Absorb image package
…ethods chore: enforce camelCase PHPUnit method names
chore: stop committing package lock files
…ages Normalize recently absorbed packages
Add focal point cropping to Image
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
| $this->assertGreaterThan(500, filesize($target)); | ||
| $this->assertLessThan(2000, filesize($target)); | ||
| $this->assertEquals(mime_content_type($target), mime_content_type($original)); |
There was a problem hiding this comment.
These fixed byte-size bounds and comparisons against checked-in reference artifacts test encoder-specific output rather than observable image behavior. Encoder output can vary across ImageMagick and codec versions even when the image is correct, so harmless dependency upgrades can fail CI. The AVIF and HEIC tests at lines 733–735 and 784–786 repeat this pattern. This violates the repository requirement to test observable behavior instead of mirroring implementation details or fixtures, and must be corrected before merging; assert properties such as decodability, format, dimensions, pixels, or a meaningful quality relationship instead.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/image/tests/ImageTest.php
Line: 596-598
Comment:
**Brittle encoder snapshots**
These fixed byte-size bounds and comparisons against checked-in reference artifacts test encoder-specific output rather than observable image behavior. Encoder output can vary across ImageMagick and codec versions even when the image is correct, so harmless dependency upgrades can fail CI. The AVIF and HEIC tests at lines 733–735 and 784–786 repeat this pattern. This violates the repository requirement to test observable behavior instead of mirroring implementation details or fixtures, and must be corrected before merging; assert properties such as decodability, format, dimensions, pixels, or a meaningful quality relationship instead.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| $image->setBorder(5, '#ff0000'); | ||
|
|
||
| $image->save($target, 'jpg', 100); | ||
|
|
||
| $this->assertIsReadable($target); | ||
| $this->assertEquals(mime_content_type($target), mime_content_type($original)); | ||
| $this->assertFileExists($target); | ||
| $this->assertNotEmpty(file_get_contents($target)); | ||
|
|
||
| $image = new \Imagick($target); | ||
| $this->assertSame('JPEG', $image->getImageFormat()); |
There was a problem hiding this comment.
Transformations remain untested
This border test invokes setBorder() but only verifies that a readable JPEG was produced, so it still passes if the border operation becomes a no-op. The opacity and border-radius tests at lines 951–988 have the same problem because they never inspect alpha values or corner pixels. This violates the repository requirement to test observable behavior and must be corrected before merging by asserting the transformed pixels or geometry.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/image/tests/ImageTest.php
Line: 915-925
Comment:
**Transformations remain untested**
This border test invokes `setBorder()` but only verifies that a readable JPEG was produced, so it still passes if the border operation becomes a no-op. The opacity and border-radius tests at lines 951–988 have the same problem because they never inspect alpha values or corner pixels. This violates the repository requirement to test observable behavior and must be corrected before merging by asserting the transformed pixels or geometry.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
Split run pushed |
|
Retired from the monorepo in utopia-php/monorepo#342. Its Split run no longer includes |
Summary
This moves
utopia-php/imageintopackages/image, so Appwrite loads it directly. It follows the playbook inrfc/monorepo.mdand comes in three commits:Add 'packages/image/' from commit 'cab2779f…': subtree import from the mirror with full history. The mirror head is the0.8.12tag Appwrite already locks, and its tree matchespackages/imageinutopia-php/monorepo(d801d07), so the dependency graph doesn't change.chore(image): mirror plumbing:mirror.ymlnow points here, and the README banner is refreshed.refactor: load image from packages/:replaceentries, drops theutopia-php/imagerequire line, and removes the package from the lock.src/Image/Image.phpmoves up tosrc/.tests/Image/ImageTest.phpmoves up totests/, and its fixture paths change to match. The test declaredAppwrite\Tests, which isn't this package's namespace, so it becomesUtopia\Image\Testswith a matchingautoload-deventry.phpstan.neon(level max,src+tests) passes as-is, with no baseline.braces_position) in the test file.There's nothing to hoist, since the package requires only PHP,
ext-imagickandext-gd, which the Appwrite image already has. The 14 MB of test fixtures are kept out of the image by the existingpackages/*/testsrule in.dockerignore. Appwrite uses the package in the Avatars module,Storage/.../Preview/Get.phpandapp/config/storage/resource_limits.php, and root PHPStan passes on all of them. The library code is byte-identical to0.8.12, so preview output doesn't change andAPP_CACHE_BUSTERstays as it is.Validation
bin/monorepo validate: all packages validbin/monorepo check image: Pint and PHPStan level max passbin/monorepo test image: 61 tests / 373 assertionsvendor/bin/phpunit --testsuite packages --filter 'Utopia\\Image\\Tests': 61 tests pass under the root autoloaderbin/monorepo split image --dry-run:3a5df569, which fast-forwards from the mirror headcab2779fgit diff --checkMerge and follow-up
Merge with a merge commit; squash and rebase are now disabled on this repository.
The
utopia-php/imagemirror already has the canonicalmainruleset (id19217880), with the split app as an always-bypass actor, so the absorb ran with--skip-ruleset.After merge: confirm
Splitpushes toutopia-php/image. Then removepackages/imagefromutopia-php/monorepo. The mirror has no open PRs, and neither does the monorepo for image.🤖 Generated with Claude Code