mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
media: generate blurhashes for video thumbnails
This commit is contained in:
parent
fa80c1adc0
commit
f180077f0a
1 changed files with 9 additions and 3 deletions
|
@ -570,12 +570,18 @@ func (gmx *Gomuks) generateVideoThumbnail(ctx context.Context, filePath string,
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to seek to start of file: %w", err)
|
||||
}
|
||||
cfg, _, err := image.DecodeConfig(tempFile)
|
||||
img, _, err := image.Decode(tempFile)
|
||||
if err != nil {
|
||||
zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to decode thumbnail image config")
|
||||
} else {
|
||||
thumbnailInfo.Width = cfg.Width
|
||||
thumbnailInfo.Height = cfg.Height
|
||||
bounds := img.Bounds()
|
||||
thumbnailInfo.Width = bounds.Dx()
|
||||
thumbnailInfo.Height = bounds.Dy()
|
||||
hash, err := blurhash.Encode(4, 3, img)
|
||||
if err != nil {
|
||||
zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to generate image blurhash")
|
||||
}
|
||||
thumbnailInfo.AnoaBlurhash = hash
|
||||
}
|
||||
_ = tempFile.Close()
|
||||
checksum := hasher.Sum(nil)
|
||||
|
|
Loading…
Add table
Reference in a new issue