# Go Image Manipulation API - Project Rules (libvips/bimg Version) ## 1. Tech Stack - Language: Go 1.26.1 - Web Framework: Fiber v3 (github.com/gofiber/fiber/v3) - Image Engine: libvips via bimg (github.com/h2non/bimg) - Database: GORM (MySQL) & Redis (Auth/Token storage) ## 2. Image Processing Logic - Use `bimg` for all transformations. - Supported Input/Output: AVIF, WEBP, PNG, JPG. - Quality: Map 1-100 values to `bimg.Options.Quality`. - Transformation Types: - `Cover`: Use `bimg.Options.Enlarge = true` and `bimg.Options.Crop = true`. - `Crop`: Use `bimg.Options.Type = bimg.ImageType` (Target format). - `Resize`: Use `bimg.Options.Width` and `bimg.Options.Height`. ## 3. Performance & Safety - **CRITICAL:** `libvips` C kaynaklarını kullanır. Bellek sızıntılarını önlemek için `bimg.VipsFree()` veya garbage collection dostu yapıları takip et. - **Async Processing:** Büyük işlemler için Fiber'in `ctx.Next()` yapısını bozmadan `pool` mantığını değerlendir. - **Redis Security:** Her manipülasyon isteği `?token=` parametresiyle gelmeli ve Redis'teki `image_id` ile eşleşmeli.