Skip to content

Add automatic image crop gravity - #13501

Merged
TorstenDittmann merged 13 commits into
mainfrom
feat/storage-auto-gravity
Sep 7, 2026
Merged

TorstenDittmann merged 13 commits into
mainfrom
feat/storage-auto-gravity

Conversation

@TorstenDittmann

Copy link
Copy Markdown
Contributor

Summary

  • add an auto image preview gravity backed by the Autogravity service
  • detect focal coordinates on demand and cache them per source file for reuse across preview variants
  • run ghcr.io/appwrite/autogravity:0.0.2 in Compose and normalize unsupported inputs before analysis
  • cover focal-point mapping, client failures, detection caching, Compose configuration, and the real Storage preview cache path

Tests

  • docker compose exec appwrite test tests/unit/Autogravity tests/unit/Docker/Compose/GeneratorTest.php
  • docker compose exec appwrite test tests/e2e/Services/Storage/StorageCustomServerTest.php --filter=testGetFilePreviewWithAutomaticGravity
  • composer lint <changed PHP files>
  • targeted PHPStan analysis of changed PHP files

@greptile-apps

greptile-apps Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds automatic focal-point-based crop gravity for Storage image previews.

  • Registers an optional Autogravity client and deploys the corresponding Compose service.
  • Sends source image bytes for focal-point analysis and caches normalized coordinates by content hash.
  • Maps detected coordinates through EXIF orientation before applying the preview crop.
  • Adds unit, Compose, and end-to-end coverage for detection, caching, orientation, configuration, and crop placement.

Confidence Score: 5/5

The PR appears safe to merge, with the previous crop-coordinate, payload-size, and behavioral-test concerns resolved.

No actionable new failures remain. The latest transport change avoids sharing Autogravity connections, while the current implementation preserves optional-service startup behavior, bounded downstream analysis, EXIF-aware focal mapping, and preview cache semantics.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Storage/Http/Buckets/Files/Preview/Get.php Integrates automatic focal-point detection into preview cropping and maps coordinates back through EXIF orientation.
src/Appwrite/Autogravity/Client.php Implements the binary Autogravity analysis request and validates service responses.
src/Appwrite/Autogravity/Detector.php Provides optional detection and content-addressed caching of focal coordinates.
src/Appwrite/Autogravity/Gravity.php Validates normalized coordinates and transforms them from oriented to original image space.
app/init/resources.php Registers the optional Autogravity dependency with a non-shared Swoole connection adapter.
docker-compose.yml Adds and wires the pinned Autogravity service into the default Compose deployment.
tests/e2e/Services/Storage/StorageCustomServerTest.php Exercises the real preview path, verifies off-center crop behavior, and checks preview caching.

Reviews (13): Last reviewed commit: "fix: avoid sharing Autogravity connectio..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/storage-auto-gravity (after).

Metric Before After Change
🚀 Requests/sec 203.99 193.37 🔴 -5.2%
⏱️ Latency P50 87.16 ms 91.86 ms 🔴 +5.4%
⏱️ Latency P95 196.56 ms 203.1 ms ⚪ +3.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 91.86 203.1 12,426 193.37 +6.54
Account 164.66 312.03 654 10.85 +15.16
TablesDB 91.9 163.31 6,758 108.15 +8.92
Storage 79.71 180.75 3,270 54.06 +11.97
Functions 122.71 256.66 1,744 29.47 +15.84

Top API waits (after)

API request Max wait (ms)
functions.variables.update 518.15
account.name.update 513.25
functions.delete 504.65
account.prefs.update 484.81
functions.variables.create 473.91

@TorstenDittmann
TorstenDittmann merged commit 1d2a0db into main Sep 7, 2026
86 of 88 checks passed
@TorstenDittmann
TorstenDittmann deleted the feat/storage-auto-gravity branch September 7, 2026 15:29
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants