fix(gallery): use correct aspect ratios
/ publish (push) Successful in 3m48s

This commit is contained in:
2026-06-08 11:18:44 +02:00
parent 763163c24e
commit c678c7aa45
3 changed files with 63 additions and 17 deletions
+11 -3
View File
@@ -45,7 +45,6 @@ func (s *Service) assembleImageList(ctx context.Context) error {
if err != nil {
return fmt.Errorf("could not read contents of %s: %w", s.cfg.Path, err)
}
slog.Debug("loaded files", "files", files)
savedHash, _ := s.cache.Do(ctx, s.cache.B().Get().Key(hashKey).Build()).AsBytes()
@@ -77,10 +76,19 @@ func (s *Service) assembleImageList(ctx context.Context) error {
continue
}
w := img.Bounds().Dx()
h := img.Bounds().Dy()
// FIX 2: Defensive check to guard against unreadable/corrupted image boundaries
if w <= 0 || h <= 0 {
slog.Warn("skipping image with zero or negative dimensions", "path", imagePath, "w", w, "h", h)
continue
}
imgs = append(imgs, Image{
UID: uid,
Width: img.Bounds().Dx(),
Height: img.Bounds().Dy(),
Width: w,
Height: h,
})
}