You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(worker): Decode image once per file in ImageSharpProcessor #153
ImageProxyMiddleware reads the source file into a byte[] once (good), but then each of the three generators (ThumbnailGenerator, FullPreviewGenerator, BlurhashGenerator) independently calls Image.LoadAsync from a fresh MemoryStream. This means a large image (e.g. a 50 MP HEIC or RAW file) is fully decoded three times per ingestion.
Proposed solution
Load Image<Rgba32> once in ImageProxyMiddleware (or in ImageSharpProcessor) and pass the already-decoded image to each generator. The simplest approach is to add an overload / new interface method that accepts a pre-loaded image:
The IImageProxyGenerator.GenerateAsync signature would need to change from Stream to Image (or a wrapper type), and the Stream-based overloads can be removed since the middleware now owns the decode lifetime.
Impact
Reduces decode work from O(n × generators) to O(n) per file. Most noticeable for high-resolution sources (HEIC, TIFF, uncompressed RAW) where decoding dominates processing time.
Activity