photo

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Orphan = "orphan-photos"
	Broken = "broken-photos"
)

Names of special "albums".

Variables

View Source
var ThumbSizes = []ThumbSize{"2400w", "1200w", "600w", "300w", "200h", "400h"}

Functions

func AlbumHash

func AlbumHash(name string) uniq.Hash

Types

type Album

type Album struct {
	uniq.Head
	Title      string        `db:"title" json:"title" formType:"textarea" title:"Title" description:"Title of an album."`
	Name       string        `db:"name" json:"name" title:"Name" required:"true" readOnly:"true" description:"A slug value that is used in album URL."`
	Public     bool          `` /* 138-byte string literal not displayed */
	Hidden     bool          `` /* 145-byte string literal not displayed */
	CoverImage uniq.Hash     `db:"cover_image" json:"cover_image,omitempty" title:"Cover Image" description:"Hash of image to use as a cover."`
	Settings   AlbumSettings `db:"settings" json:"settings" title:"Settings" description:"Additional parameters for an album."`
	// contains filtered or unexported fields
}

type AlbumImageAdder

type AlbumImageAdder interface {
	AddImages(ctx context.Context, albumHash uniq.Hash, imageHashes ...uniq.Hash) error
	SetAlbumImageTimestamp(ctx context.Context, album uniq.Hash, img uniq.Hash, ts time.Time) error
}

type AlbumImageDeleter

type AlbumImageDeleter interface {
	DeleteImages(ctx context.Context, albumHash uniq.Hash, imageHashes ...uniq.Hash) error
}

type AlbumImageFinder

type AlbumImageFinder interface {
	FindImages(ctx context.Context, albumHash uniq.Hash) ([]Image, error)
	FindPreviewImages(ctx context.Context, albumHash uniq.Hash, coverImage uniq.Hash, limit uint64) ([]Image, error)
	FindOrphanImages(ctx context.Context) ([]Image, error)
	SearchImages(ctx context.Context, query string) ([]Image, error)
	FindBrokenImages(ctx context.Context) ([]Image, error)
	FindImageAlbums(ctx context.Context, excludeAlbum uniq.Hash, imageHashes ...uniq.Hash) (map[uniq.Hash][]Album, error)
}

type AlbumSettings

type AlbumSettings struct {
	Description     string       `json:"description,omitempty" formType:"textarea" title:"Description" description:"Description of an album, can contain HTML."`
	GpxTracksHashes []uniq.Hash  `json:"gpx_tracks_hashes,omitempty" title:"GPX track hashes"`
	NewestFirst     bool         `json:"newest_first,omitempty" noTitle:"true" inlineTitle:"Newest first" description:"Show newest images at the top."`
	DailyRulers     bool         `json:"daily_rulers,omitempty" noTitle:"true" inlineTitle:"Daily rulers" description:"Show date splits between the photos."`
	Texts           []ChronoText `json:"texts,omitempty" title:"Chronological texts"`
	// Deprecated: TODO remove and implement as separate entity.
	Redirect string `json:"redirect,omitempty" title:"Relative or absolute URL to redirect to with HTTP 301 status."`
	// Deprecated: TODO remove and implement on images.
	ImageBaseURL string `json:"image_base_url,omitempty" title:"URL prefix to use for full-res images instead of local endpoint."`
	HideMap      bool   `json:"hide_map,omitempty" noTitle:"true" inlineTitle:"Hide map on album page."`

	MapTiles       string `` /* 201-byte string literal not displayed */
	MapAttribution string `json:"attribution" title:"Map attribution" description:"Map tiles attribution, overrides app default."`

	CollabKey string `json:"collab_key" title:"Collaboration key, when provided, user can add/delete album content."`
}

func (*AlbumSettings) Scan

func (s *AlbumSettings) Scan(src any) error

func (AlbumSettings) Value

func (s AlbumSettings) Value() (driver.Value, error)

type ChronoText

type ChronoText struct {
	Time time.Time `json:"time" title:"Timestamp" description:"In RFC 3339 format, e.g. 2020-01-01T01:02:03Z"`
	Text string    `json:"text" title:"Text" formType:"textarea" description:"Text, can contain HTML."`
}

type Exif

type Exif struct {
	uniq.Head

	Rating          int        `db:"rating" json:"rating" title:"Rating" minimum:"0" maximum:"5"`
	ExposureTime    string     `db:"exposure_time" json:"exposure_time" title:"Exposure"`
	ExposureTimeSec float64    `db:"exposure_time_sec" json:"exposure_time_sec" title:"Exposure (sec.)"`
	FNumber         float64    `db:"f_number" json:"f_number" title:"Aperture"`
	FocalLength     float64    `db:"focal_length" json:"focal_length" title:"Focal length"`
	ISOSpeed        int        `db:"iso_speed" json:"iso_speed" title:"ISO"`
	LensModel       string     `db:"lens_model" json:"lens_model" title:"Lens"`
	CameraMake      string     `db:"camera_make" json:"camera_make" title:"Manufacturer"`
	CameraModel     string     `db:"camera_model" json:"camera_model" title:"Camera"`
	Software        string     `db:"software" json:"software" title:"Software"`
	Digitized       *time.Time `db:"digitized" json:"digitized" title:"Digitized"`
	ProjectionType  string     `db:"projection_type" json:"projection_type" title:"Projection" description:"Use 'equirectangular' for 360 panorama."`
}

type Face added in v0.0.12

type Face struct {
	Box        *PercentBox  `json:"box"`
	Descriptor []float64    `json:"descriptor"`
	Marks      []PercentBox `json:"marks"`
}

type Gps

type Gps struct {
	uniq.Head

	Altitude  float64   `db:"altitude" title:"Altitude" json:"altitude"`
	Latitude  float64   `db:"latitude" title:"Latitude" json:"latitude"`
	Longitude float64   `db:"longitude" title:"Longitude" json:"longitude"`
	GpsTime   time.Time `db:"time" title:"GPS Timestamp" json:"time"`
}

type Gpx

type Gpx struct {
	uniq.File

	Settings sqluct.JSON[GpxSettings] `db:"settings"`
}

func (*Gpx) Index

func (g *Gpx) Index() error

type GpxSettings

type GpxSettings struct {
	Name   string  `json:"name,omitempty"`
	MinLat float64 `json:"minLat"`
	MinLon float64 `json:"minLon"`
	MaxLat float64 `json:"maxLat"`
	MaxLon float64 `json:"maxLon"`
}

func (*GpxSettings) Scan

func (s *GpxSettings) Scan(src any) error

func (GpxSettings) Value

func (s GpxSettings) Value() (driver.Value, error)

type Image

type Image struct {
	uniq.File
	Width    int64         `db:"width" title:"Width, px" json:"width" readOnly:"true"`
	Height   int64         `db:"height" title:"Height, px" json:"height" readOnly:"true"`
	BlurHash string        `db:"blurhash" title:"BlurHash" json:"blurhash" readOnly:"true"`
	PHash    uniq.Hash     `db:"phash" title:"PerceptionHash" json:"phash" readonly:"true"` // uniq.Hash is used JSON accuracy.
	TakenAt  *time.Time    `db:"taken_at" title:"Taken At" json:"taken_at"`
	Settings ImageSettings `db:"settings" json:"settings" title:"Settings" description:"Additional parameters for an album."`
}

type ImageIndexer

type ImageIndexer interface {
	Index(ctx context.Context, image Image, flags IndexingFlags) error
	QueueIndex(ctx context.Context, img Image, flags IndexingFlags)
	QueueCallback(ctx context.Context, cb func(ctx context.Context))
}

type ImageLabel deprecated added in v0.0.12

type ImageLabel struct {
	Model string  `json:"model"`
	Text  string  `json:"text"`
	Score float64 `json:"score,omitempty"`
}

Deprecated: use Label.

type ImageSettings

type ImageSettings struct {
	Description string   `json:"description,omitempty" formType:"textarea" title:"Description" description:"Description of an image, can contain HTML."`
	HTTPSources []string `json:"http_sources,omitempty"`
}

func (*ImageSettings) Scan

func (s *ImageSettings) Scan(src any) error

TODO: generalize scanner with generics.

func (ImageSettings) Value

func (s ImageSettings) Value() (driver.Value, error)

type IndexingFlags

type IndexingFlags struct {
	RebuildExif bool `formData:"rebuild_exif"`
	RebuildGps  bool `formData:"rebuild_gps"`
}

type Label added in v0.0.12

type Label struct {
	Text  string      `json:"text,omitempty"`
	Score float64     `json:"score,omitempty"`
	Box   *PercentBox `json:"box,omitempty"`
}

type MapTile

type MapTile struct {
	Data       []byte
	ModifiedAt time.Time
}

type Meta added in v0.0.12

type Meta struct {
	uniq.Head

	Data sqluct.JSON[MetaData] `db:"data" json:"data"`
}

type MetaData added in v0.0.12

type MetaData struct {
	ImageClassification []ImageLabel       `json:"image_classification,omitempty"`
	Faces               []faces.GoFaceFace `json:"faces,omitempty"`
	GeoLabel            *string            `json:"geo_label,omitempty"`
	CFResnet50          []Label            `json:"cf_resnet_50,omitempty"`
	CFLlavaDescription  *string            `json:"cf_llava_description,omitempty"`
	CFDetrResnet        []Label            `json:"cf_detr_resnet,omitempty"`
	FaceVectors         []Face             `json:"face_vectors,omitempty"`
}

type PercentBox added in v0.0.12

type PercentBox struct {
	Top    float32 `json:"t%"  description:"Top position in percent of image height."`
	Left   float32 `json:"l%" description:"Left position in percent of image width."`
	Height float32 `json:"h%,omitempty" description:"Height of the box in percent of image height."`
	Width  float32 `json:"w%,omitempty" description:"Width of the box in percent of image width."`
}

type Thumb

type Thumb struct {
	uniq.Head
	Width        uint      `db:"width" json:"width"`
	Height       uint      `db:"height" json:"height"`
	Data         []byte    `db:"data" json:"data,omitempty"`
	FilePath     string    `db:"file_path" json:"file_path,omitempty"`
	Format       ThumbSize `db:"-" json:"format,omitempty"`
	SpriteFile   string    `db:"-" json:"sprite_file,omitempty"`
	SpriteOffset int       `db:"-" json:"sprite_offset,omitempty"`
}

func (Thumb) ReadSeeker

func (t Thumb) ReadSeeker() io.ReadSeeker

type ThumbSize

type ThumbSize string

func (ThumbSize) PrepareJSONSchema

func (t ThumbSize) PrepareJSONSchema(schema *jsonschema.Schema) error

func (ThumbSize) WidthHeight

func (t ThumbSize) WidthHeight() (uint, uint, error)

type Thumbnailer

type Thumbnailer interface {
	Thumbnail(ctx context.Context, image Image, size ThumbSize) (Thumb, error)
}

Jump to

Keyboard shortcuts

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