Files
schreifuchs.ch/internal/components/images/resorce.go
T
schreifuchs 763163c24e
/ publish (push) Successful in 4m4s
feat: image gallery (#2)
Reviewed-on: #2
2026-06-01 14:07:50 +02:00

37 lines
729 B
Go

package images
import (
"os"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/pkg/config"
"github.com/valkey-io/valkey-go"
"golang.org/x/sync/semaphore"
)
type Options struct {
Width int // max width, 0 is unlimited
Height int // max Height, 0 is unlimited
Quality int // quality of the output jpeg
}
type Service struct {
fs fileSystem
cache valkey.Client
seph *semaphore.Weighted
cfg *config.Image
}
func New(fs fileSystem, cfg *config.Image, cache valkey.Client) *Service {
return &Service{
fs: fs,
cache: cache,
seph: semaphore.NewWeighted(cfg.Concurency),
cfg: cfg,
}
}
type fileSystem interface {
Read(path string) ([]byte, error)
Stat(path string) (os.FileInfo, error)
}