photoprism

package
v0.0.0-...-f83a9f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 59 Imported by: 0

Documentation

Overview

Package photoprism provides the core functionality of PhotoPrism®.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const (
	ActionIndex      = "index"
	ActionAutoIndex  = "autoindex"
	ActionImport     = "import"
	ActionAutoImport = "autoimport"
	ActionUpload     = "upload"
	ActionUnknown    = ""
)

Variables

This section is empty.

Functions

func BackupAlbums

func BackupAlbums(backupPath string, force bool) (count int, result error)

BackupAlbums creates a YAML file backup of all albums.

func CacheName

func CacheName(fileHash, namespace, cacheKey string) (cacheName string, err error)

CacheName returns an absolute cache file name based on the base path, file hash and cache namespace.

func CachePath

func CachePath(fileHash, namespace string) (cachePath string, err error)

CachePath returns a cache directory name based on the base path, file hash and cache namespace.

func Config

func Config() *config.Config

func ConvertWorker

func ConvertWorker(jobs <-chan ConvertJob)

func DeleteFiles

func DeleteFiles(files entity.Files, originals bool) (numFiles int)

DeleteFiles permanently deletes media and related sidecar files.

func DeletePhoto

func DeletePhoto(p entity.Photo, mediaFiles bool, originals bool) (numFiles int, err error)

DeletePhoto removes a photo from the index and optionally all related media files.

func ExifToolCacheName

func ExifToolCacheName(hash string) (string, error)

ExifToolCacheName returns the ExifTool metadata cache file name.

func FileName

func FileName(fileRoot, fileName string) string

FileName returns the full file name based on the root folder type.

func ImportWorker

func ImportWorker(jobs <-chan ImportJob)

func IndexWorker

func IndexWorker(jobs <-chan IndexJob)

func RelName

func RelName(fileName, directory string) string

RelName returns the relative filename.

func RestoreAlbums

func RestoreAlbums(backupPath string, force bool) (count int, result error)

RestoreAlbums restores all album YAML file backups.

func Root

func Root(fileName string) string

Root returns the file root directory.

func RootPath

func RootPath(fileName string) string

RootPath returns the file root path based on the configuration.

func RootRelName

func RootRelName(fileName string) string

RootRelName returns the relative filename, and automatically detects the root path.

func SetConfig

func SetConfig(c *config.Config)

func ThumbsWorker

func ThumbsWorker(jobs <-chan ThumbsJob)

Types

type CleanUp

type CleanUp struct {
	// contains filtered or unexported fields
}

CleanUp represents a worker that deletes orphaned index entries, sidecar files and thumbnails.

func NewCleanUp

func NewCleanUp(conf *config.Config) *CleanUp

NewCleanUp returns a new cleanup worker.

func (*CleanUp) Cache

func (w *CleanUp) Cache(opt CleanUpOptions) (deleted int, err error)

Cache removes orphaned media and thumbnail cache files.

func (*CleanUp) Cancel

func (w *CleanUp) Cancel()

Cancel stops the current operation.

func (*CleanUp) Start

func (w *CleanUp) Start(opt CleanUpOptions) (thumbs int, orphans int, sidecars int, err error)

Start index and cache cleanup.

type CleanUpOptions

type CleanUpOptions struct {
	Dry bool
}

type Convert

type Convert struct {
	// contains filtered or unexported fields
}

Convert represents a converter that can convert RAW/HEIF images to JPEG.

func NewConvert

func NewConvert(conf *config.Config) *Convert

NewConvert returns a new converter and expects the config as argument.

func (*Convert) AvcBitrate

func (c *Convert) AvcBitrate(f *MediaFile) string

AvcBitrate returns the ideal AVC encoding bitrate in megabits per second.

func (*Convert) AvcConvertCommand

func (c *Convert) AvcConvertCommand(f *MediaFile, avcName string, encoder ffmpeg.AvcEncoder) (result *exec.Cmd, useMutex bool, err error)

AvcConvertCommand returns the command for converting video files to MPEG-4 AVC.

func (*Convert) FixJpeg

func (c *Convert) FixJpeg(f *MediaFile, force bool) (*MediaFile, error)

FixJpeg tries to re-encode a broken JPEG and returns the cached image file.

func (*Convert) JpegConvertCommands

func (c *Convert) JpegConvertCommands(f *MediaFile, jpegName string, xmpName string) (result []*exec.Cmd, useMutex bool, err error)

JpegConvertCommands returns commands for converting a media file to JPEG, if possible.

func (*Convert) PngConvertCommands

func (c *Convert) PngConvertCommands(f *MediaFile, pngName string) (result []*exec.Cmd, useMutex bool, err error)

PngConvertCommands returns commands for converting a media file to PNG, if possible.

func (*Convert) Start

func (c *Convert) Start(dir string, ext []string, force bool) (err error)

Start converts all files in a directory to JPEG if possible.

func (*Convert) ToAvc

func (c *Convert) ToAvc(f *MediaFile, encoder ffmpeg.AvcEncoder, noMutex, force bool) (file *MediaFile, err error)

ToAvc converts a single video file to MPEG-4 AVC.

func (*Convert) ToImage

func (c *Convert) ToImage(f *MediaFile, force bool) (*MediaFile, error)

ToImage converts a media file to a directly supported image file format.

func (*Convert) ToJson

func (c *Convert) ToJson(f *MediaFile, force bool) (jsonName string, err error)

ToJson uses exiftool to export metadata to a json file.

type ConvertJob

type ConvertJob struct {
	// contains filtered or unexported fields
}

type Faces

type Faces struct {
	// contains filtered or unexported fields
}

Faces represents a worker for face clustering and matching.

func NewFaces

func NewFaces(conf *config.Config) *Faces

NewFaces returns a new Faces worker.

func (*Faces) Audit

func (w *Faces) Audit(fix bool) (err error)

Audit face clusters and subjects.

func (*Faces) Cancel

func (w *Faces) Cancel()

Cancel stops the current operation.

func (*Faces) Canceled

func (w *Faces) Canceled() bool

Canceled tests if face clustering and matching should be stopped.

func (*Faces) Cluster

func (w *Faces) Cluster(opt FacesOptions) (added entity.Faces, err error)

Cluster clusters indexed face embeddings.

func (*Faces) Disabled

func (w *Faces) Disabled() bool

Disabled tests if face recognition is disabled.

func (*Faces) Match

func (w *Faces) Match(opt FacesOptions) (result FacesMatchResult, err error)

Match matches markers with faces and subjects.

func (*Faces) MatchFaces

func (w *Faces) MatchFaces(faces entity.Faces, force bool, matchedBefore *time.Time) (result FacesMatchResult, err error)

MatchFaces matches markers against a slice of faces.

func (*Faces) Optimize

func (w *Faces) Optimize() (result FacesOptimizeResult, err error)

Optimize optimizes the face lookup table.

func (*Faces) Reset

func (w *Faces) Reset() (err error)

Reset removes automatically added face clusters, marker matches, and dangling subjects.

func (*Faces) Start

func (w *Faces) Start(opt FacesOptions) (err error)

Start face clustering and matching.

func (*Faces) StartDefault

func (w *Faces) StartDefault() (err error)

StartDefault starts face clustering and matching with default options.

func (*Faces) Stats

func (w *Faces) Stats() (err error)

Stats shows statistics on face embeddings.

type FacesMatchResult

type FacesMatchResult struct {
	Updated    int64
	Recognized int64
	Unknown    int64
}

FacesMatchResult represents the outcome of Faces.Match().

func (*FacesMatchResult) Add

func (r *FacesMatchResult) Add(result FacesMatchResult)

Add adds result counts.

type FacesOptimizeResult

type FacesOptimizeResult struct {
	Merged int
}

FacesOptimizeResult represents the outcome of Faces.Optimize().

type FacesOptions

type FacesOptions struct {
	Force     bool
	Threshold int
}

func FacesOptionsDefault

func FacesOptionsDefault() FacesOptions

FacesOptionsDefault returns new faces options with default values.

func (FacesOptions) SampleThreshold

func (o FacesOptions) SampleThreshold() int

SampleThreshold returns the face embeddings sample threshold for clustering.

type Files

type Files struct {
	// contains filtered or unexported fields
}

Files represents a list of already indexed file names and their unix modification timestamps.

func NewFiles

func NewFiles() *Files

NewFiles returns a new Files instance.

func (*Files) Done

func (m *Files) Done()

Done should be called after all files have been processed.

func (*Files) Exists

func (m *Files) Exists(fileName, fileRoot string) bool

Exists tests of a file exists.

func (*Files) Ignore

func (m *Files) Ignore(fileName, fileRoot string, modTime time.Time, rescan bool) bool

Ignore tests of a file requires indexing, file name must be relative to the originals path.

func (*Files) Indexed

func (m *Files) Indexed(fileName, fileRoot string, modTime time.Time, rescan bool) bool

Indexed tests of a file was already indexed without modifying the files map.

func (*Files) Init

func (m *Files) Init() error

Init fetches the list from the database once.

func (*Files) Remove

func (m *Files) Remove(fileName, fileRoot string)

Remove a file from the lookup table.

type Import

type Import struct {
	// contains filtered or unexported fields
}

Import represents an importer that can copy/move MediaFiles to the originals directory.

func NewImport

func NewImport(conf *config.Config, index *Index, convert *Convert) *Import

NewImport returns a new importer and expects its dependencies as arguments.

func (*Import) Cancel

func (imp *Import) Cancel()

Cancel stops the current import operation.

func (*Import) DestinationFilename

func (imp *Import) DestinationFilename(mainFile *MediaFile, mediaFile *MediaFile, folder string) (string, error)

DestinationFilename returns the destination filename of a MediaFile to be imported.

func (*Import) Start

func (imp *Import) Start(opt ImportOptions) fs.Done

Start imports media files from a directory and converts/indexes them as needed.

type ImportJob

type ImportJob struct {
	FileName  string
	Related   RelatedFiles
	IndexOpt  IndexOptions
	ImportOpt ImportOptions
	Imp       *Import
}

type ImportOptions

type ImportOptions struct {
	UID                    string
	Action                 string
	Albums                 []string
	Path                   string
	Move                   bool
	NonBlocking            bool
	DestFolder             string
	RemoveDotFiles         bool
	RemoveExistingFiles    bool
	RemoveEmptyDirectories bool
}

ImportOptions represents file import options.

func ImportOptionsCopy

func ImportOptionsCopy(importPath, destFolder string) ImportOptions

ImportOptionsCopy returns import options for copying files to originals (read-only).

func ImportOptionsMove

func ImportOptionsMove(importPath, destFolder string) ImportOptions

ImportOptionsMove returns import options for moving files to originals (modifies import directory).

func ImportOptionsUpload

func ImportOptionsUpload(uploadPath, destFolder string) ImportOptions

ImportOptionsUpload returns options for importing user uploads.

func (*ImportOptions) SetUser

func (o *ImportOptions) SetUser(user *entity.User) *ImportOptions

SetUser sets the user who performs the import operation.

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index represents an indexer that indexes files in the originals directory.

func NewIndex

func NewIndex(conf *config.Config, tensorFlow *classify.TensorFlow, nsfwDetector *nsfw.Detector, faceNet *face.Net, convert *Convert, files *Files, photos *Photos) *Index

NewIndex returns a new indexer and expects its dependencies as arguments.

func (*Index) Cancel

func (ind *Index) Cancel()

Cancel stops the current indexing operation.

func (*Index) Faces

func (ind *Index) Faces(jpeg *MediaFile, expected int) face.Faces

Faces finds faces in JPEG media files and returns them.

func (*Index) FileName

func (ind *Index) FileName(fileName string, o IndexOptions) (result IndexResult)

FileName indexes a single file and returns the result.

func (*Index) Labels

func (ind *Index) Labels(jpeg *MediaFile) (results classify.Labels)

Labels classifies a JPEG image and returns matching labels.

func (*Index) LastRun

func (ind *Index) LastRun() (lastRun time.Time, lastFound int)

LastRun returns the time when the index was last updated and how many files were found.

func (*Index) MediaFile

func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName, photoUID string) (result IndexResult)

MediaFile indexes a single media file.

func (*Index) NSFW

func (ind *Index) NSFW(m *MediaFile) bool

NSFW returns true if media file might be offensive and detection is enabled.

func (*Index) Start

func (ind *Index) Start(o IndexOptions) (found fs.Done, updated int)

Start indexes media files in the "originals" folder.

func (*Index) UserMediaFile

func (ind *Index) UserMediaFile(m *MediaFile, o IndexOptions, originalName, photoUID, userUID string) (result IndexResult)

UserMediaFile indexes a single media file owned by a user.

type IndexJob

type IndexJob struct {
	FileName string
	Related  RelatedFiles
	IndexOpt IndexOptions
	Ind      *Index
}

type IndexOptions

type IndexOptions struct {
	UID             string
	Action          string
	Path            string
	Rescan          bool
	Convert         bool
	Stack           bool
	FacesOnly       bool
	SkipArchived    bool
	ByteLimit       int64
	ResolutionLimit int
}

IndexOptions represents file indexing options.

func IndexOptionsAll

func IndexOptionsAll() IndexOptions

IndexOptionsAll returns new index options with all options set to true.

func IndexOptionsFacesOnly

func IndexOptionsFacesOnly() IndexOptions

IndexOptionsFacesOnly returns new index options for updating faces only.

func IndexOptionsNone

func IndexOptionsNone() IndexOptions

IndexOptionsNone returns new index options with all options set to false.

func IndexOptionsSingle

func IndexOptionsSingle() IndexOptions

IndexOptionsSingle returns new index options for unstacked, single files.

func NewIndexOptions

func NewIndexOptions(path string, rescan, convert, stack, facesOnly, skipArchived bool) IndexOptions

NewIndexOptions returns new index options instance.

func (*IndexOptions) SetUser

func (o *IndexOptions) SetUser(user *entity.User) *IndexOptions

SetUser sets the user who performs the index operation.

func (*IndexOptions) SkipUnchanged

func (o *IndexOptions) SkipUnchanged() bool

SkipUnchanged checks if unchanged media files should be skipped.

type IndexResult

type IndexResult struct {
	Status   IndexStatus
	Err      error
	FileID   uint
	FileUID  string
	PhotoID  uint
	PhotoUID string
}

IndexResult represents a media file indexing result.

func IndexMain

func IndexMain(related *RelatedFiles, ind *Index, o IndexOptions) (result IndexResult)

IndexMain indexes the main file from a group of related files and returns the result.

func IndexRelated

func IndexRelated(related RelatedFiles, ind *Index, o IndexOptions) (result IndexResult)

IndexRelated indexes a group of related files and returns the result.

func (IndexResult) Archived

func (r IndexResult) Archived() bool

Archived checks whether a media file was skipped because it is archived.

func (IndexResult) Failed

func (r IndexResult) Failed() bool

Failed checks if indexing has failed.

func (IndexResult) FileError

func (r IndexResult) FileError() (string, error)

FileError checks if there is a file error and returns it.

func (IndexResult) Indexed

func (r IndexResult) Indexed() bool

Indexed checks whether a media file was successfully indexed.

func (IndexResult) Skipped

func (r IndexResult) Skipped() bool

Skipped checks whether a media file was skipped while indexing.

func (IndexResult) Stacked

func (r IndexResult) Stacked() bool

Stacked checks whether a media file was stacked while indexing.

func (IndexResult) String

func (r IndexResult) String() string

String returns the indexing result as string.

func (IndexResult) Success

func (r IndexResult) Success() bool

Success checks whether a media file was successfully indexed or skipped.

type IndexStatus

type IndexStatus string
const (
	IndexUpdated   IndexStatus = "updated"
	IndexAdded     IndexStatus = "added"
	IndexStacked   IndexStatus = "stacked"
	IndexSkipped   IndexStatus = "skipped"
	IndexDuplicate IndexStatus = "skipped duplicate"
	IndexArchived  IndexStatus = "skipped archived"
	IndexFailed    IndexStatus = "failed"
)

type Label

type Label struct {
	Name        string   `json:"label"`       // Label name
	Source      string   `json:"source"`      // Where was this label found / detected?
	Uncertainty int      `json:"uncertainty"` // >= 0
	Priority    int      `json:"priority"`    // >= 0
	Categories  []string `json:"categories"`  // List of similar labels
}

Label represents a MediaFile label (automatically created).

func NewLocationLabel

func NewLocationLabel(name string, uncertainty int, priority int) Label

NewLocationLabel returns a new labels for a location and expects name, uncertainty and priority as arguments.

type Labels

type Labels []Label

Labels is list of MediaFile labels.

func (Labels) AppendLabel

func (l Labels) AppendLabel(label Label) Labels

func (Labels) Keywords

func (l Labels) Keywords() (result []string)

func (Labels) Len

func (l Labels) Len() int

func (Labels) Less

func (l Labels) Less(i, j int) bool

func (Labels) Swap

func (l Labels) Swap(i, j int)

func (Labels) Title

func (l Labels) Title(fallback string) string

type MediaFile

type MediaFile struct {
	// contains filtered or unexported fields
}

MediaFile represents a single photo, video, sidecar, or other supported media file.

func NewMediaFile

func NewMediaFile(fileName string) (*MediaFile, error)

NewMediaFile returns a new media file and automatically resolves any symlinks.

func NewMediaFileSkipResolve

func NewMediaFileSkipResolve(fileName string, fileNameResolved string) (*MediaFile, error)

NewMediaFileSkipResolve returns a new media file without resolving symlinks. This is useful because if it is known that the filename is fully resolved, it is much faster.

func (*MediaFile) AbsPrefix

func (m *MediaFile) AbsPrefix(stripSequence bool) string

AbsPrefix returns the directory and base filename without any extensions.

func (*MediaFile) AspectRatio

func (m *MediaFile) AspectRatio() float32

AspectRatio returns the aspect ratio of a MediaFile.

func (*MediaFile) BaseName

func (m *MediaFile) BaseName() string

BaseName returns the filename without path.

func (*MediaFile) BasePrefix

func (m *MediaFile) BasePrefix(stripSequence bool) string

BasePrefix returns the filename base without any extensions and path.

func (*MediaFile) Bounds

func (m *MediaFile) Bounds() image.Rectangle

Bounds returns the media dimensions as image.Rectangle.

func (*MediaFile) CameraMake

func (m *MediaFile) CameraMake() string

CameraMake returns the make of the camera with which the file was created.

func (*MediaFile) CameraModel

func (m *MediaFile) CameraModel() string

CameraModel returns the camera model with which the media file was created.

func (*MediaFile) CanonicalName

func (m *MediaFile) CanonicalName() string

CanonicalName returns the canonical name of a media file.

func (*MediaFile) CanonicalNameFromFile

func (m *MediaFile) CanonicalNameFromFile() string

CanonicalNameFromFile returns the canonical name of a file derived from the image name.

func (*MediaFile) CanonicalNameFromFileWithDirectory

func (m *MediaFile) CanonicalNameFromFileWithDirectory() string

CanonicalNameFromFileWithDirectory gets the canonical name for a MediaFile including the directory.

func (*MediaFile) ChangeOrientation

func (m *MediaFile) ChangeOrientation(val int) (err error)

ChangeOrientation changes the file orientation.

func (*MediaFile) CheckType

func (m *MediaFile) CheckType() error

CheckType returns an error if the file extension is missing or invalid, see https://github.com/photoprism/photoprism/issues/3518 for details.

func (*MediaFile) Checksum

func (m *MediaFile) Checksum() string

Checksum returns the CRC32 checksum of a media file.

func (*MediaFile) ColorProfile

func (m *MediaFile) ColorProfile() string

ColorProfile returns the ICC color profile name.

func (*MediaFile) Colors

func (m *MediaFile) Colors(thumbPath string) (perception colors.ColorPerception, err error)

Colors returns the ColorPerception of an image (only JPEG supported).

func (*MediaFile) Copy

func (m *MediaFile) Copy(dest string) error

Copy a MediaFile to another file by destinationFilename.

func (*MediaFile) CreateExifToolJson

func (m *MediaFile) CreateExifToolJson(convert *Convert) error

CreateExifToolJson extracts metadata to a JSON file using Exiftool.

func (*MediaFile) CreateThumbnails

func (m *MediaFile) CreateThumbnails(thumbPath string, force bool) (err error)

CreateThumbnails creates the default thumbnail sizes if the media file is a JPEG and they don't exist yet (except force is true).

func (*MediaFile) DateCreated

func (m *MediaFile) DateCreated() time.Time

DateCreated returns the media creation time in UTC.

func (*MediaFile) DecodeConfig

func (m *MediaFile) DecodeConfig() (_ *image.Config, err error)

DecodeConfig extracts the raw dimensions from the header of natively supported image file formats.

func (*MediaFile) Dir

func (m *MediaFile) Dir() string

Dir returns the file path.

func (*MediaFile) Duration

func (m *MediaFile) Duration() time.Duration

Duration returns the duration is the media content is playable.

func (*MediaFile) EditedName

func (m *MediaFile) EditedName() string

EditedName returns the corresponding edited image file name as used by Apple (e.g. IMG_E12345.JPG).

func (*MediaFile) Empty

func (m *MediaFile) Empty() bool

Empty checks if the file is empty.

func (*MediaFile) ExceedsBytes

func (m *MediaFile) ExceedsBytes(limit int64) (err error, fileSize int64)

ExceedsBytes checks if the file exceeds the specified size limit in bytes.

func (*MediaFile) ExceedsResolution

func (m *MediaFile) ExceedsResolution(limit int) (err error, resolution int)

ExceedsResolution checks if an image in a natively supported format exceeds the configured resolution limit in megapixels.

func (*MediaFile) ExifSupported

func (m *MediaFile) ExifSupported() bool

ExifSupported returns true if parsing exif metadata is supported for the media file type.

func (*MediaFile) ExifToolJsonName

func (m *MediaFile) ExifToolJsonName() (string, error)

ExifToolJsonName returns the cached ExifTool metadata file name.

func (*MediaFile) Exists

func (m *MediaFile) Exists() bool

Exists checks if a media file exists by filename.

func (*MediaFile) Exposure

func (m *MediaFile) Exposure() string

Exposure returns the exposure time as string.

func (*MediaFile) Extension

func (m *MediaFile) Extension() string

Extension returns the filename extension of this media file.

func (*MediaFile) FNumber

func (m *MediaFile) FNumber() float32

FNumber returns the F number with which the media file was created.

func (*MediaFile) FileName

func (m *MediaFile) FileName() string

FileName returns the filename.

func (*MediaFile) FileSize

func (m *MediaFile) FileSize() int64

FileSize returns the file size in bytes.

func (*MediaFile) FileType

func (m *MediaFile) FileType() fs.Type

FileType returns the file type (jpg, gif, tiff,...).

func (*MediaFile) FocalLength

func (m *MediaFile) FocalLength() int

FocalLength return the length of the focal for a file.

func (*MediaFile) HasFileType

func (m *MediaFile) HasFileType(fileType fs.Type) bool

HasFileType checks if the file has the given file type.

func (*MediaFile) HasMediaType

func (m *MediaFile) HasMediaType(mediaType media.Type) bool

HasMediaType checks if the file has is the given media type.

func (*MediaFile) HasPreviewImage

func (m *MediaFile) HasPreviewImage() bool

HasPreviewImage returns true if the file has or is a JPEG or PNG image.

func (*MediaFile) HasSameName

func (m *MediaFile) HasSameName(f *MediaFile) bool

HasSameName compares a media file with another media file and returns if their filenames are matching or not.

func (*MediaFile) HasSidecarJson

func (m *MediaFile) HasSidecarJson() bool

HasSidecarJson returns true if this file has or is a json sidecar file.

func (*MediaFile) HasTimeAndPlace

func (m *MediaFile) HasTimeAndPlace() bool

func (*MediaFile) Hash

func (m *MediaFile) Hash() string

Hash returns the SHA1 hash of a media file.

func (*MediaFile) Height

func (m *MediaFile) Height() int

Height returns the height dimension of a MediaFile.

func (*MediaFile) InOriginals

func (m *MediaFile) InOriginals() bool

InOriginals checks if the file is stored in the 'originals' folder.

func (*MediaFile) InSidecar

func (m *MediaFile) InSidecar() bool

InSidecar checks if the file is stored in the 'sidecar' folder.

func (*MediaFile) IsAVIF

func (m *MediaFile) IsAVIF() bool

IsAVIF checks if the file is an AV1 Image File Format image with a supported file type extension.

func (*MediaFile) IsAVIFS

func (m *MediaFile) IsAVIFS() bool

IsAVIFS checks if the file is an AVIF image sequence with a supported file type extension.

func (*MediaFile) IsAnimated

func (m *MediaFile) IsAnimated() bool

IsAnimated returns true if it is a video or animated image.

func (*MediaFile) IsAnimatedImage

func (m *MediaFile) IsAnimatedImage() bool

IsAnimatedImage checks if the file is an animated image.

func (*MediaFile) IsBMP

func (m *MediaFile) IsBMP() bool

IsBMP checks if the file is a bitmap image with a supported file type extension.

func (*MediaFile) IsDNG

func (m *MediaFile) IsDNG() bool

IsDNG checks if the file is a Adobe Digital Negative (DNG) image with a supported file type extension.

func (*MediaFile) IsGIF

func (m *MediaFile) IsGIF() bool

IsGIF checks if the file is a GIF image with a supported file type extension.

func (*MediaFile) IsHEIC

func (m *MediaFile) IsHEIC() bool

IsHEIC checks if the file is a High Efficiency Image Container (HEIC) image with a supported file type extension.

func (*MediaFile) IsHEICS

func (m *MediaFile) IsHEICS() bool

IsHEICS checks if the file is a HEIC image sequence with a supported file type extension.

func (*MediaFile) IsHEIF

func (m *MediaFile) IsHEIF() bool

IsHEIF checks if the file is a High Efficiency Image File Format (HEIF) container with a supported file type extension.

func (*MediaFile) IsImage

func (m *MediaFile) IsImage() bool

IsImage checks if the file is an image.

func (*MediaFile) IsImageNative

func (m *MediaFile) IsImageNative() bool

IsImageNative returns true if it is a natively supported image file.

func (*MediaFile) IsImageOther

func (m *MediaFile) IsImageOther() bool

IsImageOther returns true if this is a PNG, GIF, BMP, TIFF, or WebP file.

func (*MediaFile) IsJSON

func (m *MediaFile) IsJSON() bool

IsJSON checks if the file is a JSON sidecar file with a supported file type extension.

func (*MediaFile) IsJpeg

func (m *MediaFile) IsJpeg() bool

IsJpeg checks if the file is a JPEG image with a supported file type extension.

func (*MediaFile) IsJpegXL

func (m *MediaFile) IsJpegXL() bool

IsJpegXL checks if the file is a JPEG XL image with a supported file type extension.

func (*MediaFile) IsLive

func (m *MediaFile) IsLive() bool

IsLive checks if the file is a live photo.

func (*MediaFile) IsMedia

func (m *MediaFile) IsMedia() bool

IsMedia returns true if this is a media file (photo or video, not sidecar or other).

func (*MediaFile) IsPNG

func (m *MediaFile) IsPNG() bool

IsPNG checks if the file is a PNG image with a supported file type extension.

func (*MediaFile) IsPreviewImage

func (m *MediaFile) IsPreviewImage() bool

IsPreviewImage return true if this media file is a JPEG or PNG image.

func (*MediaFile) IsRaw

func (m *MediaFile) IsRaw() bool

IsRaw returns true if this is a RAW file.

func (*MediaFile) IsSVG

func (m *MediaFile) IsSVG() bool

IsSVG returns true if this is a SVG vector graphics.

func (*MediaFile) IsSidecar

func (m *MediaFile) IsSidecar() bool

IsSidecar checks if the file is a metadata sidecar file, independent of the storage location.

func (*MediaFile) IsTIFF

func (m *MediaFile) IsTIFF() bool

IsTIFF checks if the file is a TIFF image with a supported file type extension.

func (*MediaFile) IsVector

func (m *MediaFile) IsVector() bool

IsVector returns true if this is a vector graphics.

func (*MediaFile) IsVideo

func (m *MediaFile) IsVideo() bool

IsVideo returns true if this is a video file.

func (*MediaFile) IsWebP

func (m *MediaFile) IsWebP() bool

IsWebP checks if the file is a WebP image file with a supported file type extension.

func (*MediaFile) IsXMP

func (m *MediaFile) IsXMP() bool

IsXMP returns true if this is a XMP sidecar file.

func (*MediaFile) Iso

func (m *MediaFile) Iso() int

Iso returns the iso rating as int.

func (*MediaFile) LensMake

func (m *MediaFile) LensMake() string

LensMake returns the make of the Lens.

func (*MediaFile) LensModel

func (m *MediaFile) LensModel() string

LensModel returns the lens model of a media file.

func (*MediaFile) Location

func (m *MediaFile) Location() (*entity.Cell, error)

Location returns the S2 cell entity of a MediaFile.

func (*MediaFile) Media

func (m *MediaFile) Media() media.Type

Media returns the media content type (video, image, raw, sidecar,...).

func (*MediaFile) Megapixels

func (m *MediaFile) Megapixels() (resolution int)

Megapixels returns the resolution in megapixels if possible.

func (*MediaFile) MetaData

func (m *MediaFile) MetaData() (result meta.Data)

MetaData returns exif meta data of a media file.

func (*MediaFile) MimeType

func (m *MediaFile) MimeType() string

MimeType returns the mime type.

func (*MediaFile) ModTime

func (m *MediaFile) ModTime() time.Time

ModTime returns the file modification time.

func (*MediaFile) Move

func (m *MediaFile) Move(dest string) error

Move file to a new destination with the filename provided in parameter.

func (*MediaFile) NeedsExifToolJson

func (m *MediaFile) NeedsExifToolJson() bool

NeedsExifToolJson tests if an ExifTool JSON file needs to be created.

func (*MediaFile) NeedsTranscoding

func (m *MediaFile) NeedsTranscoding() bool

NeedsTranscoding checks whether the media file is a video or an animated image and should be transcoded to a playable format.

func (*MediaFile) NotAnimated

func (m *MediaFile) NotAnimated() bool

NotAnimated checks if the file is not a video or an animated image.

func (*MediaFile) Ok

func (m *MediaFile) Ok() bool

Ok checks if the file has a name, exists and is not empty.

func (*MediaFile) Orientation

func (m *MediaFile) Orientation() int

Orientation returns the Exif orientation of the media file.

func (*MediaFile) PathNameInfo

func (m *MediaFile) PathNameInfo(stripSequence bool) (fileRoot, fileBase, relativePath, relativeName string)

PathNameInfo returns file name infos for indexing.

func (*MediaFile) Portrait

func (m *MediaFile) Portrait() bool

Portrait tests if the image is a portrait.

func (*MediaFile) PreviewImage

func (m *MediaFile) PreviewImage() (*MediaFile, error)

PreviewImage returns a PNG or JPEG version of the media file, if exists.

func (*MediaFile) ReadExifToolJson

func (m *MediaFile) ReadExifToolJson() error

ReadExifToolJson reads metadata from a cached ExifTool JSON file.

func (*MediaFile) RelName

func (m *MediaFile) RelName(directory string) string

RelName returns the relative filename.

func (*MediaFile) RelPath

func (m *MediaFile) RelPath(directory string) string

RelPath returns the relative path without filename.

func (*MediaFile) RelPrefix

func (m *MediaFile) RelPrefix(directory string, stripSequence bool) string

RelPrefix returns the relative path and file name prefix.

func (*MediaFile) RelatedFiles

func (m *MediaFile) RelatedFiles(stripSequence bool) (result RelatedFiles, err error)

RelatedFiles returns files which are related to this file.

func (*MediaFile) RelatedSidecarFiles

func (m *MediaFile) RelatedSidecarFiles(stripSequence bool) (files []string, err error)

RelatedSidecarFiles finds additional sidecar files with naming schemes not matching the default glob pattern for related files. see https://github.com/photoprism/photoprism/issues/2983 for further information.

func (*MediaFile) Remove

func (m *MediaFile) Remove() error

Remove permanently removes a media file.

func (*MediaFile) RemoveSidecarFiles

func (m *MediaFile) RemoveSidecarFiles() (numFiles int, err error)

RemoveSidecarFiles permanently removes related sidecar files.

func (*MediaFile) RenameSidecarFiles

func (m *MediaFile) RenameSidecarFiles(oldFileName string) (renamed map[string]string, err error)

RenameSidecarFiles moves related sidecar files.

func (*MediaFile) Resample

func (m *MediaFile) Resample(path string, sizeName thumb.Name) (img image.Image, err error)

Resample returns a resampled image of the file.

func (*MediaFile) Root

func (m *MediaFile) Root() string

Root returns the file root directory.

func (*MediaFile) RootPath

func (m *MediaFile) RootPath() string

RootPath returns the file root path based on the configuration.

func (*MediaFile) RootRelName

func (m *MediaFile) RootRelName() string

RootRelName returns the relative filename, and automatically detects the root path.

func (*MediaFile) RootRelPath

func (m *MediaFile) RootRelPath() string

RootRelPath returns the relative path and automatically detects the root path.

func (*MediaFile) SetFileName

func (m *MediaFile) SetFileName(fileName string)

SetFileName sets the filename to the given string.

func (*MediaFile) SetModTime

func (m *MediaFile) SetModTime(modTime time.Time) *MediaFile

SetModTime sets the file modification time.

func (*MediaFile) SidecarJsonName

func (m *MediaFile) SidecarJsonName() string

SidecarJsonName returns the corresponding JSON sidecar file name as used by Google Photos (and potentially other apps).

func (*MediaFile) SkipTranscoding

func (m *MediaFile) SkipTranscoding() bool

SkipTranscoding checks if the media file is not animated or has already been transcoded to a playable format.

func (*MediaFile) Stat

func (m *MediaFile) Stat() (size int64, mod time.Time, err error)

Stat calls os.Stat() to return the file size and modification time, or an error if this failed.

func (*MediaFile) SubDir

func (m *MediaFile) SubDir(dir string) string

SubDir returns a sub directory name.

func (*MediaFile) TakenAt

func (m *MediaFile) TakenAt() (time.Time, string)

TakenAt returns the media creation time in UTC and the source from which it originates.

func (*MediaFile) Thumbnail

func (m *MediaFile) Thumbnail(path string, sizeName thumb.Name) (filename string, err error)

Thumbnail returns a thumbnail filename.

func (*MediaFile) TimeZone

func (m *MediaFile) TimeZone() string

TimeZone returns the time zone where the photo was taken.

func (*MediaFile) VideoInfo

func (m *MediaFile) VideoInfo() video.Info

VideoInfo returns video information if this is a video file or has a video embedded.

func (*MediaFile) Width

func (m *MediaFile) Width() int

Width return the width dimension of a MediaFile.

type MediaFiles

type MediaFiles []*MediaFile

MediaFiles represents a slice of files.

func (MediaFiles) Len

func (f MediaFiles) Len() int

Len returns the length of the file slice.

func (MediaFiles) Less

func (f MediaFiles) Less(i, j int) bool

Less compares two files based on the filename.

func (MediaFiles) Swap

func (f MediaFiles) Swap(i, j int)

Swap the position of two files in the slice.

type Moments

type Moments struct {
	// contains filtered or unexported fields
}

Moments represents a worker that creates albums based on popular locations, dates and labels.

func NewMoments

func NewMoments(conf *config.Config) *Moments

NewMoments returns a new Moments worker.

func (*Moments) Cancel

func (w *Moments) Cancel()

Cancel stops the current operation.

func (*Moments) MigrateSlug

func (w *Moments) MigrateSlug(m query.Moment, albumType string)

MigrateSlug updates deprecated moment slugs if needed.

func (*Moments) Start

func (w *Moments) Start() (err error)

Start creates albums based on popular locations, dates and categories.

type Photos

type Photos struct {
	// contains filtered or unexported fields
}

Photos represents photo id lookup table, sorted by date and S2 cell id.

func NewPhotos

func NewPhotos() *Photos

NewPhotos returns a new Photos instance.

func (*Photos) Find

func (m *Photos) Find(takenAt time.Time, cellId string) uint

Find returns the photo ID for a time and cell id.

func (*Photos) Init

func (m *Photos) Init() error

Init fetches the list from the database once.

func (*Photos) Remove

func (m *Photos) Remove(takenAt time.Time, cellId string)

Remove a photo from the lookup table.

type Places

type Places struct {
	// contains filtered or unexported fields
}

Places represents a geo data worker.

func NewPlaces

func NewPlaces(conf *config.Config) *Places

NewPlaces returns a new Places worker.

func (*Places) Cancel

func (w *Places) Cancel()

Cancel stops the current operation.

func (*Places) Canceled

func (w *Places) Canceled() bool

Canceled tests if the worker should be stopped.

func (*Places) Start

func (w *Places) Start() (updated []string, err error)

Start runs the Places worker.

func (*Places) UpdatePhotos

func (w *Places) UpdatePhotos() (affected int, err error)

UpdatePhotos updates all location-related photo metadata in the index.

type Purge

type Purge struct {
	// contains filtered or unexported fields
}

Purge represents a worker that removes missing files from search results.

func NewPurge

func NewPurge(conf *config.Config, files *Files) *Purge

NewPurge returns a new purge worker.

func (*Purge) Cancel

func (w *Purge) Cancel()

Cancel stops the current operation.

func (*Purge) Start

func (w *Purge) Start(opt PurgeOptions) (purgedFiles map[string]bool, purgedPhotos map[string]bool, updated int, err error)

Start removes missing files from search results.

type PurgeOptions

type PurgeOptions struct {
	Path   string
	Ignore fs.Done
	Dry    bool
	Hard   bool
	Force  bool
}

type RelatedFiles

type RelatedFiles struct {
	Files MediaFiles
	Main  *MediaFile
}

RelatedFiles represents a list of related files to be indexed or imported.

func (RelatedFiles) Count

func (m RelatedFiles) Count() int

Count returns the number of files without the main file.

func (RelatedFiles) HasPreview

func (m RelatedFiles) HasPreview() bool

HasPreview checks if the list of files contains a PNG or JPEG image to render a preview in the UI.

func (RelatedFiles) Len

func (m RelatedFiles) Len() int

Len returns the number of related files.

func (RelatedFiles) MainFileType

func (m RelatedFiles) MainFileType() string

MainFileType returns the main file type as string.

func (RelatedFiles) MainLogName

func (m RelatedFiles) MainLogName() string

MainLogName returns the main file name for logging.

func (RelatedFiles) String

func (m RelatedFiles) String() string

String returns file names as string.

type S

type S []string

type Thumbs

type Thumbs struct {
	// contains filtered or unexported fields
}

Thumbs represents a thumbnail image generator.

func NewThumbs

func NewThumbs(conf *config.Config) *Thumbs

NewThumbs returns a new thumbnails generator and expects the config as argument.

func (*Thumbs) Dir

func (w *Thumbs) Dir(dir string, force bool) (fs.Done, error)

Dir creates thumbnail images for files found in a given path.

func (*Thumbs) Start

func (w *Thumbs) Start(dir string, force, originalsOnly bool) (err error)

Start creates thumbnails for files in the originals and sidecar folders.

type ThumbsJob

type ThumbsJob struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL