diff --git a/internal/entity/file.go b/internal/entity/file.go index 88b54c56c..cc334c327 100644 --- a/internal/entity/file.go +++ b/internal/entity/file.go @@ -446,21 +446,16 @@ func (m *File) Save() error { return m.ResolvePrimary() } -// UpdateVideoInfos updates related video infos based on this file. +// UpdateVideoInfos updates missing video metadata from the primary image. +// see https://github.com/photoprism/photoprism/pull/3588#issuecomment-1683429455 func (m *File) UpdateVideoInfos() error { if m.PhotoID <= 0 { return fmt.Errorf("file has invalid photo id") } - // Update video dimensions, if necessary. - type Dimensions struct { - FileWidth int - FileHeight int - FileOrientation int - FileAspectRatio float32 - } - - dimensions := Dimensions{} + // Set the video dimensions from the primary image if it could not be determined from the video metadata. + // see https://github.com/photoprism/photoprism/blob/develop/internal/photoprism/index_mediafile.go + dimensions := FileDimensions{} if err := deepcopier.Copy(&dimensions).From(m); err != nil { return err @@ -468,16 +463,9 @@ func (m *File) UpdateVideoInfos() error { return err } - // Update video appearance, if necessary. - type Appearance struct { - FileMainColor string - FileColors string - FileLuminance string - FileDiff int - FileChroma int16 - } - - appearance := Appearance{} + // Set the video appearance from the primary file if it could not be detected e.g. from a JPEG sidecar file. + // see https://github.com/photoprism/photoprism/blob/develop/internal/photoprism/index_mediafile.go + appearance := FileAppearance{} if err := deepcopier.Copy(&appearance).From(m); err != nil { return err diff --git a/internal/entity/file_metadata.go b/internal/entity/file_metadata.go new file mode 100644 index 000000000..ff1ba7edf --- /dev/null +++ b/internal/entity/file_metadata.go @@ -0,0 +1,20 @@ +package entity + +// FileDimensions represents metadata related to the size and orientation of a file. +// see File.UpdateVideoInfos() +type FileDimensions struct { + FileWidth int + FileHeight int + FileOrientation int + FileAspectRatio float32 +} + +// FileAppearance represents file metadata related to colors, luminance and perception. +// see File.UpdateVideoInfos() +type FileAppearance struct { + FileMainColor string + FileColors string + FileLuminance string + FileDiff int + FileChroma int16 +} diff --git a/internal/photoprism/index_mediafile.go b/internal/photoprism/index_mediafile.go index b27059c31..5e3d239f7 100644 --- a/internal/photoprism/index_mediafile.go +++ b/internal/photoprism/index_mediafile.go @@ -657,7 +657,7 @@ func (ind *Index) UserMediaFile(m *MediaFile, o IndexOptions, originalName, phot file.FilePortrait = primaryFile.FilePortrait } - // Set the appearance of the video from the primary file. In a future version, a still image extracted from the + // Set the video appearance from the primary file. In a future version, a still image extracted from the // video could be used for this purpose if the primary image is not directly derived from the video file, // e.g. in live photo stacks, see https://github.com/photoprism/photoprism/pull/3588#issuecomment-1683429455 if primaryFile.FileDiff > 0 {