photoprism: github.com/photoprism/photoprism/internal/photoprism Index | Files

package photoprism

import "github.com/photoprism/photoprism/internal/photoprism"

Package photoprism contains PhotoPrism core functionality.

Copyright (c) 2018 - 2020 Michael Mayer <hello@photoprism.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

PhotoPrism™ is a registered trademark of Michael Mayer.  You may use it as required
to describe our software, run your own server, for educational purposes, but not for
offering commercial goods, products, or services without prior written permission.
In other words, please ask.

Feel free to send an e-mail to hello@photoprism.org 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.org/developer-guide/

Index

Package Files

colors.go config.go convert.go convert_worker.go filename.go files.go import.go import_options.go import_worker.go index.go index_mediafile.go index_options.go index_related.go index_worker.go label.go location.go mediafile.go mediafiles.go metadata.go moments.go photoprism.go purge.go purge_options.go related.go resample.go resample_worker.go timezone.go

func Config Uses

func Config() *config.Config

func ConvertWorker Uses

func ConvertWorker(jobs <-chan ConvertJob)

func FileName Uses

func FileName(fileRoot, fileName string) string

func ImportWorker Uses

func ImportWorker(jobs <-chan ImportJob)

func IndexWorker Uses

func IndexWorker(jobs <-chan IndexJob)

func ResampleWorker Uses

func ResampleWorker(jobs <-chan ResampleJob)

func SetConfig Uses

func SetConfig(c *config.Config)

type Convert Uses

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

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

func NewConvert Uses

func NewConvert(conf *config.Config) *Convert

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

func (*Convert) JpegConvertCommand Uses

func (c *Convert) JpegConvertCommand(mf *MediaFile, jpegName string, xmpName string) (result *exec.Cmd, useMutex bool, err error)

JpegConvertCommand returns the command for converting files to JPEG, depending on the format.

func (*Convert) Start Uses

func (c *Convert) Start(path string) error

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

func (*Convert) ToJpeg Uses

func (c *Convert) ToJpeg(image *MediaFile) (*MediaFile, error)

ToJpeg converts a single image file to JPEG if possible.

func (*Convert) ToJson Uses

func (c *Convert) ToJson(mf *MediaFile) (*MediaFile, error)

ToJson uses exiftool to export metadata to a json file.

type ConvertJob Uses

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

type Files Uses

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

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

func NewFiles Uses

func NewFiles() *Files

NewFiles returns a new Files instance pointer.

func (*Files) Ignore Uses

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 Uses

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 Uses

func (m *Files) Init() error

Init fetches the list from the database once.

type Import Uses

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

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

func NewImport Uses

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

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

func (*Import) Cancel Uses

func (imp *Import) Cancel()

Cancel stops the current import operation.

func (*Import) DestinationFilename Uses

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

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

func (*Import) Start Uses

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

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

type ImportJob Uses

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

type ImportOptions Uses

type ImportOptions struct {
    Albums                 []string
    Path                   string
    Move                   bool
    RemoveDotFiles         bool
    RemoveExistingFiles    bool
    RemoveEmptyDirectories bool
}

func ImportOptionsCopy Uses

func ImportOptionsCopy(path string) ImportOptions

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

func ImportOptionsMove Uses

func ImportOptionsMove(path string) ImportOptions

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

type Index Uses

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

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

func NewIndex Uses

func NewIndex(conf *config.Config, tensorFlow *classify.TensorFlow, nsfwDetector *nsfw.Detector, convert *Convert) *Index

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

func (*Index) Cancel Uses

func (ind *Index) Cancel()

Cancel stops the current indexing operation.

func (*Index) File Uses

func (ind *Index) File(name string) (result IndexResult)

File indexes a single file and returns the result.

func (*Index) MediaFile Uses

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

func (*Index) NSFW Uses

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

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

func (*Index) Start Uses

func (ind *Index) Start(opt IndexOptions) fs.Done

Start indexes media files in the originals directory.

type IndexJob Uses

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

type IndexOptions Uses

type IndexOptions struct {
    Path    string
    Rescan  bool
    Convert bool
}

func IndexOptionsAll Uses

func IndexOptionsAll() IndexOptions

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

func IndexOptionsNone Uses

func IndexOptionsNone() IndexOptions

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

func (*IndexOptions) SkipUnchanged Uses

func (o *IndexOptions) SkipUnchanged() bool

type IndexResult Uses

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

func IndexMain Uses

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

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

func IndexRelated Uses

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

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

func (IndexResult) Failed Uses

func (r IndexResult) Failed() bool

func (IndexResult) Indexed Uses

func (r IndexResult) Indexed() bool

func (IndexResult) Stacked Uses

func (r IndexResult) Stacked() bool

func (IndexResult) String Uses

func (r IndexResult) String() string

func (IndexResult) Success Uses

func (r IndexResult) Success() bool

type IndexStatus Uses

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 Uses

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 Uses

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 Uses

type Labels []Label

Labels is list of MediaFile labels.

func (Labels) AppendLabel Uses

func (l Labels) AppendLabel(label Label) Labels

func (Labels) Keywords Uses

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

func (Labels) Len Uses

func (l Labels) Len() int

func (Labels) Less Uses

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

func (Labels) Swap Uses

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

func (Labels) Title Uses

func (l Labels) Title(fallback string) string

type MediaFile Uses

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

MediaFile represents a single photo, video or sidecar file.

func NewMediaFile Uses

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

NewMediaFile returns a new media file.

func (*MediaFile) AbsPrefix Uses

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

AbsPrefix returns the directory and base filename without any extensions.

func (*MediaFile) AspectRatio Uses

func (m *MediaFile) AspectRatio() float32

AspectRatio returns the aspect ratio of a MediaFile.

func (*MediaFile) BaseName Uses

func (m *MediaFile) BaseName() string

BaseName returns the filename without path.

func (*MediaFile) BasePrefix Uses

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

BasePrefix returns the filename base without any extensions and path.

func (*MediaFile) CameraMake Uses

func (m *MediaFile) CameraMake() string

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

func (*MediaFile) CameraModel Uses

func (m *MediaFile) CameraModel() string

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

func (*MediaFile) CanonicalName Uses

func (m *MediaFile) CanonicalName() string

CanonicalName returns the canonical name of a media file.

func (*MediaFile) CanonicalNameFromFile Uses

func (m *MediaFile) CanonicalNameFromFile() string

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

func (*MediaFile) CanonicalNameFromFileWithDirectory Uses

func (m *MediaFile) CanonicalNameFromFileWithDirectory() string

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

func (*MediaFile) Checksum Uses

func (m *MediaFile) Checksum() string

Checksum returns the CRC32 checksum of a media file.

func (*MediaFile) Colors Uses

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

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

func (*MediaFile) Copy Uses

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

Copy a MediaFile to another file by destinationFilename.

func (*MediaFile) DateCreated Uses

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

DateCreated returns only the date on which the media file was probably taken in UTC.

func (*MediaFile) Dir Uses

func (m *MediaFile) Dir() string

Dir returns the file path.

func (*MediaFile) EditedName Uses

func (m *MediaFile) EditedName() string

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

func (*MediaFile) ExifSupported Uses

func (m *MediaFile) ExifSupported() bool

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

func (*MediaFile) Exists Uses

func (m *MediaFile) Exists() bool

Exists checks if a media file exists by filename.

func (*MediaFile) Exposure Uses

func (m *MediaFile) Exposure() string

Exposure returns the exposure time as string.

func (*MediaFile) Extension Uses

func (m *MediaFile) Extension() string

Extension returns the filename extension of this media file.

func (*MediaFile) FNumber Uses

func (m *MediaFile) FNumber() float32

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

func (*MediaFile) FileName Uses

func (m *MediaFile) FileName() string

FileName returns the filename.

func (*MediaFile) FileSize Uses

func (m *MediaFile) FileSize() int64

FileSize returns the file size in bytes.

func (*MediaFile) FileType Uses

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

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

func (*MediaFile) FocalLength Uses

func (m *MediaFile) FocalLength() int

FocalLength return the length of the focal for a file.

func (*MediaFile) HasFileType Uses

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

HasFileType returns true if this is the given type.

func (*MediaFile) HasJpeg Uses

func (m *MediaFile) HasJpeg() bool

ContainsJpeg returns true if this file has or is a jpeg media file.

func (*MediaFile) HasJson Uses

func (m *MediaFile) HasJson() bool

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

func (*MediaFile) HasSameName Uses

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) HasTimeAndPlace Uses

func (m *MediaFile) HasTimeAndPlace() bool

func (*MediaFile) Hash Uses

func (m *MediaFile) Hash() string

Hash returns the SHA1 hash of a media file.

func (*MediaFile) Height Uses

func (m *MediaFile) Height() int

Height returns the height dimension of a MediaFile.

func (*MediaFile) IsBitmap Uses

func (m *MediaFile) IsBitmap() bool

IsBitmap returns true if this is a bitmap file.

func (*MediaFile) IsGif Uses

func (m *MediaFile) IsGif() bool

IsGif returns true if this is a GIF file.

func (*MediaFile) IsHEIF Uses

func (m *MediaFile) IsHEIF() bool

IsHEIF returns true if this is a High Efficiency Image File Format file.

func (*MediaFile) IsImageOther Uses

func (m *MediaFile) IsImageOther() bool

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

func (*MediaFile) IsJpeg Uses

func (m *MediaFile) IsJpeg() bool

IsJpeg return true if this media file is a JPEG image.

func (*MediaFile) IsJson Uses

func (m *MediaFile) IsJson() bool

IsJson return true if this media file is a json sidecar file.

func (*MediaFile) IsMedia Uses

func (m *MediaFile) IsMedia() bool

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

func (*MediaFile) IsPhoto Uses

func (m *MediaFile) IsPhoto() bool

IsPhoto returns true if this file is a photo / image.

func (*MediaFile) IsPlayableVideo Uses

func (m *MediaFile) IsPlayableVideo() bool

IsPlayableVideo returns true if this is a supported video file format.

func (*MediaFile) IsPng Uses

func (m *MediaFile) IsPng() bool

IsPng returns true if this is a PNG file.

func (*MediaFile) IsRaw Uses

func (m *MediaFile) IsRaw() bool

IsRaw returns true if this is a RAW file.

func (*MediaFile) IsSidecar Uses

func (m *MediaFile) IsSidecar() bool

IsSidecar returns true if this is a sidecar file (containing metadata).

func (*MediaFile) IsTiff Uses

func (m *MediaFile) IsTiff() bool

IsTiff returns true if this is a TIFF file.

func (*MediaFile) IsVideo Uses

func (m *MediaFile) IsVideo() bool

IsVideo returns true if this is a video file.

func (*MediaFile) IsXMP Uses

func (m *MediaFile) IsXMP() bool

IsXMP returns true if this is a XMP sidecar file.

func (*MediaFile) Iso Uses

func (m *MediaFile) Iso() int

Iso returns the iso rating as int.

func (*MediaFile) Jpeg Uses

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

Jpeg returns a the JPEG version of the media file (if exists).

func (*MediaFile) JsonName Uses

func (m *MediaFile) JsonName() string

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

func (*MediaFile) LensMake Uses

func (m *MediaFile) LensMake() string

LensMake returns the make of the Lens.

func (*MediaFile) LensModel Uses

func (m *MediaFile) LensModel() string

LensModel returns the lens model of a media file.

func (*MediaFile) Location Uses

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

Location returns the S2 cell entity of a MediaFile.

func (*MediaFile) MediaType Uses

func (m *MediaFile) MediaType() fs.MediaType

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

func (*MediaFile) Megapixels Uses

func (m *MediaFile) Megapixels() int

Megapixels returns the resolution in megapixels.

func (*MediaFile) MetaData Uses

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

MetaData returns exif meta data of a media file.

func (*MediaFile) MimeType Uses

func (m *MediaFile) MimeType() string

MimeType returns the mime type.

func (*MediaFile) ModTime Uses

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

ModTime returns the file modification time.

func (*MediaFile) Move Uses

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

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

func (*MediaFile) Orientation Uses

func (m *MediaFile) Orientation() int

Orientation returns the orientation of a MediaFile.

func (*MediaFile) PathNameInfo Uses

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

PathNameInfo returns file name infos for indexing.

func (*MediaFile) Portrait Uses

func (m *MediaFile) Portrait() bool

Portrait tests if the image is a portrait.

func (*MediaFile) RelName Uses

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

RelName returns the relative filename.

func (*MediaFile) RelPath Uses

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

RelPath returns the relative path without filename.

func (*MediaFile) RelPrefix Uses

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

RelPrefix returns the relative path and file name prefix.

func (*MediaFile) RelatedFiles Uses

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

RelatedFiles returns files which are related to this file.

func (*MediaFile) Remove Uses

func (m *MediaFile) Remove() error

Remove a media file.

func (*MediaFile) Resample Uses

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

Thumbnail returns a resampled image of the file.

func (*MediaFile) ResampleDefault Uses

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

func (*MediaFile) Root Uses

func (m *MediaFile) Root() string

Root returns the file root directory.

func (*MediaFile) RootRelName Uses

func (m *MediaFile) RootRelName() string

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

func (*MediaFile) SetFileName Uses

func (m *MediaFile) SetFileName(fileName string)

SetFileName sets the filename to the given string.

func (*MediaFile) Stat Uses

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

Stat returns the media file size and modification time rounded to seconds

func (*MediaFile) SubDir Uses

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

SubDir returns a sub directory name.

func (*MediaFile) TakenAt Uses

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

TakenAt returns the date on which the media file was taken in UTC and the source of this information.

func (*MediaFile) Thumbnail Uses

func (m *MediaFile) Thumbnail(path string, typeName string) (filename string, err error)

Thumbnail returns a thumbnail filename.

func (*MediaFile) TimeZone Uses

func (m *MediaFile) TimeZone() string

TimeZone returns the time zone where the photo was taken.

func (*MediaFile) Width Uses

func (m *MediaFile) Width() int

Width return the width dimension of a MediaFile.

type MediaFiles Uses

type MediaFiles []*MediaFile

MediaFiles represents a slice of files.

func (MediaFiles) Len Uses

func (f MediaFiles) Len() int

Len returns the length of the file slice.

func (MediaFiles) Less Uses

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

Less compares two files based on the filename.

func (MediaFiles) Swap Uses

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

Swap the position of two files in the slice.

type Moments Uses

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

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

func NewMoments Uses

func NewMoments(conf *config.Config) *Moments

NewMoments returns a new purge worker.

func (*Moments) Cancel Uses

func (m *Moments) Cancel()

Cancel stops the current operation.

func (*Moments) Start Uses

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

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

type Purge Uses

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

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

func NewPurge Uses

func NewPurge(conf *config.Config) *Purge

NewPurge returns a new purge worker.

func (*Purge) Cancel Uses

func (prg *Purge) Cancel()

Cancel stops the current operation.

func (*Purge) Start Uses

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

Start removes missing files from search results.

type PurgeOptions Uses

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

type RelatedFiles Uses

type RelatedFiles struct {
    Files MediaFiles
    Main  *MediaFile
}

List of related files for importing and indexing.

func (RelatedFiles) ContainsJpeg Uses

func (m RelatedFiles) ContainsJpeg() bool

ContainsJpeg returns true if related file list contains a JPEG.

func (RelatedFiles) Len Uses

func (m RelatedFiles) Len() int

Len returns the number of related files.

func (RelatedFiles) String Uses

func (m RelatedFiles) String() string

String returns file names as string.

type Resample Uses

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

Resample represents a thumbnail generator.

func NewResample Uses

func NewResample(conf *config.Config) *Resample

NewResample returns a new thumbnail generator and expects the config as argument.

func (*Resample) Start Uses

func (rs *Resample) Start(force bool) (err error)

Start creates default thumbnails for all files in originalsPath.

type ResampleJob Uses

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

Package photoprism imports 39 packages (graph) and is imported by 4 packages. Updated 2020-07-24. Refresh now. Tools for package owners.