immich

package
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package immich provides functions to interact with the Immich API.

It includes functionality for retrieving random images, fetching images associated with specific people or albums, and getting image statistics. The package also implements caching mechanisms to optimize API calls.

Index

Constants

View Source
const (
	PortraitOrientation  ImageOrientation = "PORTRAIT"
	LandscapeOrientation ImageOrientation = "LANDSCAPE"
	SquareOrientation    ImageOrientation = "SQUARE"

	ImageType ImmichAssetType = "IMAGE"
	VideoType ImmichAssetType = "VIDEO"
	AudioType ImmichAssetType = "AUDIO"
	OtherType ImmichAssetType = "OTHER"

	AssetSizeThumbnail string = "thumbnail"
	AssetSizeOriginal  string = "original"
)

Variables

This section is empty.

Functions

func ApiCacheCount

func ApiCacheCount() int

func FlushApiCache

func FlushApiCache()

Types

type ExifInfo

type ExifInfo struct {
	Make             string    `json:"make"`
	Model            string    `json:"model"`
	ExifImageWidth   int       `json:"exifImageWidth"`
	ExifImageHeight  int       `json:"exifImageHeight"`
	FileSizeInByte   int       `json:"fileSizeInByte"`
	Orientation      string    `json:"orientation"`
	DateTimeOriginal time.Time `json:"dateTimeOriginal"`
	ModifyDate       time.Time `json:"modifyDate"`
	TimeZone         string    `json:"timeZone"`
	LensModel        string    `json:"lensModel"`
	FNumber          float64   `json:"fNumber"`
	FocalLength      float64   `json:"focalLength"`
	Iso              int       `json:"iso"`
	ExposureTime     string    `json:"exposureTime"`
	Latitude         float64   `json:"latitude"`
	Longitude        float64   `json:"longitude"`
	City             string    `json:"city"`
	State            string    `json:"state"`
	Country          string    `json:"country"`
	Description      string    `json:"description"`
	ProjectionType   any       `json:"-"` // `json:"projectionType"`
	ImageOrientation ImageOrientation
}

type Face

type Face struct {
	ID            string `json:"id"`
	ImageHeight   int    `json:"imageHeight"`
	ImageWidth    int    `json:"imageWidth"`
	BoundingBoxX1 int    `json:"boundingBoxX1"`
	BoundingBoxX2 int    `json:"boundingBoxX2"`
	BoundingBoxY1 int    `json:"boundingBoxY1"`
	BoundingBoxY2 int    `json:"boundingBoxY2"`
}

type ImageOrientation

type ImageOrientation string

type ImmichAlbum

type ImmichAlbum struct {
	ID         string        `json:"id"`
	AlbumName  string        `json:"albumName"`
	Assets     []ImmichAsset `json:"assets"`
	AssetCount int           `json:"assetCount"`
}

type ImmichAlbums

type ImmichAlbums []ImmichAlbum

func (*ImmichAlbums) RemoveExcludedAlbums

func (a *ImmichAlbums) RemoveExcludedAlbums(exclude []string)

RemoveExcludedAlbums filters out albums whose IDs are in the exclude slice.

type ImmichApiCall

type ImmichApiCall func(string, string, []byte) ([]byte, error)

type ImmichAsset

type ImmichAsset struct {
	ID               string          `json:"id"`
	DeviceAssetID    string          `json:"-"` // `json:"deviceAssetId"`
	OwnerID          string          `json:"-"` // `json:"ownerId"`
	DeviceID         string          `json:"-"` // `json:"deviceId"`
	LibraryID        string          `json:"-"` // `json:"libraryId"`
	Type             ImmichAssetType `json:"type"`
	OriginalPath     string          `json:"-"` // `json:"originalPath"`
	OriginalFileName string          `json:"originalFileName"`
	OriginalMimeType string          `json:"originalMimeType"`
	Resized          bool            `json:"-"` // `json:"resized"`
	Thumbhash        string          `json:"-"` // `json:"thumbhash"`
	FileCreatedAt    time.Time       `json:"-"` // `json:"fileCreatedAt"`
	FileModifiedAt   time.Time       `json:"-"` // `json:"fileModifiedAt"`
	LocalDateTime    time.Time       `json:"localDateTime"`
	UpdatedAt        time.Time       `json:"-"` // `json:"updatedAt"`
	IsFavorite       bool            `json:"isFavorite"`
	IsArchived       bool            `json:"isArchived"`
	IsTrashed        bool            `json:"isTrashed"`
	Duration         string          `json:"-"` // `json:"duration"`
	ExifInfo         ExifInfo        `json:"exifInfo"`
	LivePhotoVideoID any             `json:"-"` // `json:"livePhotoVideoId"`
	People           []Person        `json:"people"`
	UnassignedFaces  []Face          `json:"unassignedFaces"`
	Checksum         string          `json:"checksum"`
	StackCount       any             `json:"-"` // `json:"stackCount"`
	IsOffline        bool            `json:"-"` // `json:"isOffline"`
	HasMetadata      bool            `json:"-"` // `json:"hasMetadata"`
	DuplicateID      any             `json:"-"` // `json:"duplicateId"`

	// Data added and used by Kiosk
	RatioWanted     ImageOrientation `json:"-"`
	IsPortrait      bool             `json:"-"`
	IsLandscape     bool             `json:"-"`
	KioskSource     kiosk.Source     `json:"-"`
	KioskSourceName string           `json:"-"`
}

func NewImage

func NewImage(base config.Config) ImmichAsset

NewImage returns a new image instance

func (*ImmichAsset) AlbumImageCount

func (i *ImmichAsset) AlbumImageCount(albumID string, requestID string) (int, error)

AlbumImageCount retrieves the number of images in a specific album from Immich.

func (*ImmichAsset) AssetInfo

func (i *ImmichAsset) AssetInfo(requestID string) error

AssetInfo fetches the image information from Immich

func (*ImmichAsset) CheckForFaces

func (i *ImmichAsset) CheckForFaces(requestID string)

func (*ImmichAsset) FacesCenterPoint

func (i *ImmichAsset) FacesCenterPoint() (float64, float64)

FacesCenterPoint calculates the center point of all detected faces in an image as percentages. It analyzes both assigned (People) and unassigned faces, finding the bounding box that encompasses all faces and returning its center as x,y percentages relative to the image dimensions. Returns (0,0) if no faces are detected or if image dimensions are invalid.

func (*ImmichAsset) FacesCenterPointPX

func (i *ImmichAsset) FacesCenterPointPX() (float64, float64)

FacesCenterPointPX calculates the center point of all detected faces in an image in pixels. It analyzes both assigned (People) and unassigned faces, finding the bounding box that encompasses all faces and returning its center as x,y pixel coordinates. Returns (0,0) if no faces are detected or if all bounding boxes are empty.

func (*ImmichAsset) ImagePreview

func (i *ImmichAsset) ImagePreview() ([]byte, error)

ImagePreview fetches the raw image data from Immich

func (*ImmichAsset) OLDRandomImageOfPerson

func (i *ImmichAsset) OLDRandomImageOfPerson(personID, requestID, kioskDeviceID string, isPrefetch bool) error

DEPRECIATED RandomImageOfPerson retrieve random image of person from Immich

func (*ImmichAsset) PersonImageCount

func (i *ImmichAsset) PersonImageCount(personID, requestID string) (int, error)

PersonImageCount returns the number of images associated with a specific person in Immich.

func (*ImmichAsset) PersonName added in v0.14.6

func (i *ImmichAsset) PersonName(personID string)

func (*ImmichAsset) RandomAlbumFromAllAlbums

func (i *ImmichAsset) RandomAlbumFromAllAlbums(requestID string, excludedAlbums []string) (string, error)

RandomAlbumFromAllAlbums returns a random album ID from all albums. It takes a requestID for API call tracking and a slice of excluded album IDs. The selection is weighted based on the number of assets in each album. Returns an error if there are no available albums after exclusions or if the API call fails.

func (*ImmichAsset) RandomAlbumFromSharedAlbums

func (i *ImmichAsset) RandomAlbumFromSharedAlbums(requestID string, excludedAlbums []string) (string, error)

RandomAlbumFromSharedAlbums returns a random album ID from shared albums. It takes a requestID for API call tracking and a slice of excluded album IDs. The selection is weighted based on the number of assets in each album. Returns an error if there are no available albums after exclusions or if the API call fails.

func (*ImmichAsset) RandomImage

func (i *ImmichAsset) RandomImage(requestID, kioskDeviceID string, isPrefetch bool) error

GetRandomImage retrieve a random image from Immich

func (*ImmichAsset) RandomImageFromAlbum

func (i *ImmichAsset) RandomImageFromAlbum(albumID, requestID, kioskDeviceID string, isPrefetch bool) error

RandomImageFromAlbum retrieve random image within a specified album from Immich

func (*ImmichAsset) RandomImageFromFavourites

func (i *ImmichAsset) RandomImageFromFavourites(requestID, kioskDeviceID string, isPrefetch bool) error

RandomImageFromFavourites retrieves a random favorite image from the Immich server.

func (*ImmichAsset) RandomImageOfPerson

func (i *ImmichAsset) RandomImageOfPerson(personID, requestID, kioskDeviceID string, isPrefetch bool) error

RandomImageOfPerson retrieve random image of person from Immich

type ImmichAssetType

type ImmichAssetType string

type ImmichError

type ImmichError struct {
	Message    []string `json:"message"`
	Error      string   `json:"error"`
	StatusCode int      `json:"statusCode"`
}

type ImmichPersonStatistics

type ImmichPersonStatistics struct {
	Assets int `json:"assets"`
}

type ImmichSearchMetadataResponse

type ImmichSearchMetadataResponse struct {
	Assets struct {
		Total    int    `json:"total"`
		NextPage string `json:"nextPage"`
	} `json:"assets"`
}

type ImmichSearchRandomBody

type ImmichSearchRandomBody struct {
	City          string   `url:"city,omitempty" json:"city,omitempty"`
	Country       string   `url:"country,omitempty" json:"country,omitempty"`
	CreatedAfter  string   `url:"createdAfter,omitempty" json:"createdAfter,omitempty"`
	CreatedBefore string   `url:"createdBefore,omitempty" json:"createdBefore,omitempty"`
	DeviceID      string   `url:"deviceId,omitempty" json:"deviceId,omitempty"`
	IsArchived    bool     `url:"isArchived,omitempty" json:"isArchived,omitempty"`
	IsEncoded     bool     `url:"isEncoded,omitempty" json:"isEncoded,omitempty"`
	IsFavorite    bool     `url:"isFavorite,omitempty" json:"isFavorite,omitempty"`
	IsMotion      bool     `url:"isMotion,omitempty" json:"isMotion,omitempty"`
	IsNotInAlbum  bool     `url:"isNotInAlbum,omitempty" json:"isNotInAlbum,omitempty"`
	IsOffline     bool     `url:"isOffline,omitempty" json:"isOffline,omitempty"`
	IsVisible     bool     `url:"isVisible,omitempty" json:"isVisible,omitempty"`
	LensModel     string   `url:"lensModel,omitempty" json:"lensModel,omitempty"`
	LibraryID     string   `url:"libraryId,omitempty" json:"libraryId,omitempty"`
	Make          string   `url:"make,omitempty" json:"make,omitempty"`
	Model         string   `url:"model,omitempty" json:"model,omitempty"`
	PersonIds     []string `url:"personIds,omitempty" json:"personIds,omitempty"`
	Size          int      `url:"size,omitempty" json:"size,omitempty"`
	State         string   `url:"state,omitempty" json:"state,omitempty"`
	TakenAfter    string   `url:"takenAfter,omitempty" json:"takenAfter,omitempty"`
	TakenBefore   string   `url:"takenBefore,omitempty" json:"takenBefore,omitempty"`
	TrashedAfter  string   `url:"trashedAfter,omitempty" json:"trashedAfter,omitempty"`
	TrashedBefore string   `url:"trashedBefore,omitempty" json:"trashedBefore,omitempty"`
	Type          string   `url:"type,omitempty" json:"type,omitempty"`
	UpdatedAfter  string   `url:"updatedAfter,omitempty" json:"updatedAfter,omitempty"`
	UpdatedBefore string   `url:"updatedBefore,omitempty" json:"updatedBefore,omitempty"`
	WithArchived  bool     `url:"withArchived,omitempty" json:"withArchived,omitempty"`
	WithDeleted   bool     `url:"withDeleted,omitempty" json:"withDeleted,omitempty"`
	WithExif      bool     `url:"withExif,omitempty" json:"withExif,omitempty"`
	WithPeople    bool     `url:"withPeople,omitempty" json:"withPeople,omitempty"`
	WithStacked   bool     `url:"withStacked,omitempty" json:"withStacked,omitempty"`
	Page          int      `url:"page,omitempty" json:"page,omitempty"`
}

type Person

type Person struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	BirthDate     any       `json:"-"` // `json:"birthDate"`
	ThumbnailPath string    `json:"-"` // `json:"thumbnailPath"`
	IsHidden      bool      `json:"-"` // `json:"isHidden"`
	UpdatedAt     time.Time `json:"-"` // `json:"updatedAt"`
	Faces         []Face    `json:"faces"`
}

Jump to

Keyboard shortcuts

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