H1: beeldpijplijn in Core.Media (Magick.NET achter IImageProcessor), pure functies met property-tests, uploadwacht
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
- [x] NFR Requirements (construction/nfr-requirements/)
|
||||
- [x] NFR Design (construction/nfr-design/)
|
||||
- [x] Infrastructure Design (media directory; construction/infrastructure-design/)
|
||||
- [ ] Code Generation - EXECUTE (per unit H0 to H6)
|
||||
- [ ] Code Generation - per unit: H0 done, H1 done (image pipeline), H2 to H6 open
|
||||
- [ ] Build and Test - EXECUTE
|
||||
### 🟡 OPERATIONS PHASE
|
||||
- [ ] SKIP (Q19 = B; points go into the joint production checklist)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# H1 Image pipeline: code summary
|
||||
|
||||
Built 2026-11-16 on `feature/hero-module`. Build and tests of the unit run green (Core tests 876 of 876, of which 79 are new; the CI solution filter builds).
|
||||
|
||||
## What was built
|
||||
|
||||
| Area | Files |
|
||||
|---|---|
|
||||
| Types, options, rejection | `Core/Media/MediaTypes.cs` (`ImageFormat`, `ImageInfo`, `Ratio` wide 3:2 and tall 4:5, `FocusSetting`, `CropRect`, `VariantSpec`, `RatioPlan`, `RenderedImage`, `MediaAddress`), `Core/Media/ImageProcessing.cs` (`ImageRejection`, `ImageRejectedException` with stable codes, `MediaOptions`, `IImageProcessor`, `MediaStatus`, `MediaProcessingGate`) |
|
||||
| Pure functions | `ImageSignature` (format from the first bytes; SVG, PDF, executables never recognised), `FocusMath` (crop around the focus, round-half-up so the TypeScript twin matches), `VariantPlanner` (widths never above the crop, WebP always, AVIF when possible, JPEG when WebP is missing), `MediaPaths` (set hash, address, strict allow-listed parser) |
|
||||
| Guard | `MediaUploadGuard` (availability, counted byte limit, signature, library inspection with pixel and side limits, processing slot), `GuardedUpload` |
|
||||
| Registration and self-test | `MediaServiceCollectionExtensions.AddCmsMedia`, `ImageProcessorSelfTest` (hosted; a failed self-test only turns uploads off) |
|
||||
| Library | new project `SlpModularCms.Core.Media.Magick` (`MagickImageProcessor`, `AddMagickImageProcessor`), Magick.NET-Q8-AnyCPU 15.1.0. Deviation from the design text: the library lives in its own project so that hosts that never process images (the slave) do not carry the 35 MB native library; the abstractions stay in Core |
|
||||
| Tests | `Core.Tests/Media/`: pure functions with FsCheck properties (crop inside the image, focus inside the crop, ratio kept, zoom monotonic, planner never upscales, ladder ascending, signature never throws on random input), known vectors shared with the future TypeScript twin, address tests (including path tricks), signature tests, guard tests (limits, busy, unavailable), Magick processor tests on generated fixtures (formats, orientation, animated GIF, metadata stripped, crop keeps the chosen side, AVIF output, truncated and garbage files, mismatched format, strip of metadata) |
|
||||
| Solution | project added to `SlpModularCms.sln` (folder Application) and `SlpModularCms.Ci.slnf` |
|
||||
|
||||
## Decisions made while building
|
||||
|
||||
- Truncated or damaged files are rejected as `corrupt`: the library returns a partly decoded picture with a warning for them, so decode warnings that mean damage (premature end, truncated, corrupt, ...) are turned into a rejection.
|
||||
- The orientation is applied before cropping and `InspectAsync` reports the oriented size, so the plan and the crop always use the same numbers.
|
||||
- HEIC stays a declared capability only; no real HEIC test photo yet (to add when one is available, per Bryan).
|
||||
- The original is stored as received unless it carries metadata: `StripMetadataAsync` removes it (the pixels are re-encoded at quality 92 or the source quality, whichever is higher).
|
||||
|
||||
## Not done in this unit (planned elsewhere)
|
||||
|
||||
Media store, endpoint and directory check (H3); the `Hero:*` options and the rate-limit policies (H2/H3); the self-contained publish check of the native library (done with the first project that references it, H2).
|
||||
Reference in New Issue
Block a user