From 368c97f0f85f243796a0407960dc5a2ccad24bab Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:10:41 +0000 Subject: [bugfix] take into account rotation when generating thumbnail (#3147) * take into account rotation when generating thumbnail, simplify ffprobe output to show only fields we need * only show rotation side data * remove unnecessary comment * fix code comments * remove debug logging --- internal/media/processingmedia.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/media/processingmedia.go') diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index 32c0531bc..b68d8d680 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -176,10 +176,11 @@ func (p *ProcessingMedia) store(ctx context.Context) error { // This will always be used regardless of type, // as even audio files may contain embedded album art. width, height, framerate := result.ImageMeta() + aspect := util.Div(float32(width), float32(height)) p.media.FileMeta.Original.Width = width p.media.FileMeta.Original.Height = height p.media.FileMeta.Original.Size = (width * height) - p.media.FileMeta.Original.Aspect = util.Div(float32(width), float32(height)) + p.media.FileMeta.Original.Aspect = aspect p.media.FileMeta.Original.Framerate = util.PtrIf(framerate) p.media.FileMeta.Original.Duration = util.PtrIf(float32(result.duration)) p.media.FileMeta.Original.Bitrate = util.PtrIf(result.bitrate) @@ -218,11 +219,11 @@ func (p *ProcessingMedia) store(ctx context.Context) error { if width > 0 && height > 0 { // Determine thumbnail dimensions to use. - thumbWidth, thumbHeight := thumbSize(width, height) + thumbWidth, thumbHeight := thumbSize(width, height, aspect, result.rotation) p.media.FileMeta.Small.Width = thumbWidth p.media.FileMeta.Small.Height = thumbHeight p.media.FileMeta.Small.Size = (thumbWidth * thumbHeight) - p.media.FileMeta.Small.Aspect = float32(thumbWidth) / float32(thumbHeight) + p.media.FileMeta.Small.Aspect = aspect // Generate a thumbnail image from input image path. thumbpath, err = ffmpegGenerateThumb(ctx, temppath, -- cgit v1.2.3