image

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedImageFormat = errors.New("unsupported image format")

	// ErrNotSupportedForThumbnail is returned if the image format is not supported for thumbnail generation
	ErrNotSupportedForThumbnail = errors.New("unsupported image format for thumbnail")
)
View Source
var (
	ErrNotImageFile = errors.New("not an image file")
)

Functions

func AddPerformer added in v0.7.0

func AddPerformer(ctx context.Context, qb PartialUpdater, i *models.Image, performerID int) error

func AddTag added in v0.7.0

func AddTag(ctx context.Context, qb PartialUpdater, i *models.Image, tagID int) error

func CountByPerformerID added in v0.7.0

func CountByPerformerID(ctx context.Context, r CountQueryer, id int) (int, error)

func CountByStudioID added in v0.7.0

func CountByStudioID(ctx context.Context, r CountQueryer, id int) (int, error)

func CountByTagID added in v0.7.0

func CountByTagID(ctx context.Context, r CountQueryer, id int) (int, error)

func FindByGalleryID added in v0.14.0

func FindByGalleryID(ctx context.Context, r Queryer, galleryID int, sortBy string, sortDir models.SortDirectionEnum) ([]*models.Image, error)

func GetStudioName

func GetStudioName(ctx context.Context, reader studio.Finder, image *models.Image) (string, error)

GetStudioName returns the name of the provided image's studio. It returns an empty string if there is no studio assigned to the image.

func GetVipsPath added in v0.10.0

func GetVipsPath() string

func IsCover

func IsCover(img *models.Image) bool

func PathsFilter added in v0.12.0

func PathsFilter(paths []string) *models.ImageFilterType

func Query added in v0.11.0

func Query(ctx context.Context, qb Queryer, imageFilter *models.ImageFilterType, findFilter *models.FindFilterType) ([]*models.Image, error)

Query queries for images using the provided filters.

func QueryOptions added in v0.11.0

func QueryOptions(imageFilter *models.ImageFilterType, findFilter *models.FindFilterType, count bool) models.ImageQueryOptions

QueryOptions returns a ImageQueryResult populated with the provided filters.

func ToBasicJSON

func ToBasicJSON(image *models.Image) *jsonschema.Image

ToBasicJSON converts a image object into its JSON object equivalent. It does not convert the relationships to other objects, with the exception of cover image.

Types

type CountQueryer added in v0.17.0

type CountQueryer interface {
	QueryCount(ctx context.Context, imageFilter *models.ImageFilterType, findFilter *models.FindFilterType) (int, error)
}

type Destroyer added in v0.12.0

type Destroyer interface {
	Destroy(ctx context.Context, id int) error
}

type FileDeleter added in v0.12.0

type FileDeleter struct {
	*file.Deleter

	Paths *paths.Paths
}

FileDeleter is an extension of file.Deleter that handles deletion of image files.

func (*FileDeleter) MarkGeneratedFiles added in v0.12.0

func (d *FileDeleter) MarkGeneratedFiles(image *models.Image) error

MarkGeneratedFiles marks for deletion the generated files for the provided image.

type FinderByFile added in v0.17.0

type FinderByFile interface {
	FindByFileID(ctx context.Context, fileID file.ID) ([]*models.Image, error)
	FindByZipFileID(ctx context.Context, zipFileID file.ID) ([]*models.Image, error)
}

type FinderCreatorUpdater added in v0.17.0

type FinderCreatorUpdater interface {
	FindByFileID(ctx context.Context, fileID file.ID) ([]*models.Image, error)
	FindByFolderID(ctx context.Context, folderID file.FolderID) ([]*models.Image, error)
	FindByFingerprints(ctx context.Context, fp []file.Fingerprint) ([]*models.Image, error)
	Create(ctx context.Context, newImage *models.ImageCreateInput) error
	UpdatePartial(ctx context.Context, id int, updatedImage models.ImagePartial) (*models.Image, error)
	AddFileID(ctx context.Context, id int, fileID file.ID) error
	models.GalleryIDLoader
	models.ImageFileLoader
}

type FullCreatorUpdater added in v0.17.0

type FullCreatorUpdater interface {
	FinderCreatorUpdater
	Update(ctx context.Context, updatedImage *models.Image) error
}

type GalleryFinder added in v0.17.0

type GalleryFinder interface {
	FindByPath(ctx context.Context, p string) ([]*models.Gallery, error)
	FindUserGalleryByTitle(ctx context.Context, title string) ([]*models.Gallery, error)
}

type GalleryFinderCreator added in v0.17.0

type GalleryFinderCreator interface {
	FindByFileID(ctx context.Context, fileID file.ID) ([]*models.Gallery, error)
	FindByFolderID(ctx context.Context, folderID file.FolderID) ([]*models.Gallery, error)
	Create(ctx context.Context, newObject *models.Gallery, fileIDs []file.ID) error
}

type Importer

type Importer struct {
	ReaderWriter        FullCreatorUpdater
	FileFinder          file.Getter
	StudioWriter        studio.NameFinderCreator
	GalleryFinder       GalleryFinder
	PerformerWriter     performer.NameFinderCreator
	TagWriter           tag.NameFinderCreator
	Input               jsonschema.Image
	MissingRefBehaviour models.ImportMissingRefEnum

	ID int
	// contains filtered or unexported fields
}

func (*Importer) Create

func (i *Importer) Create(ctx context.Context) (*int, error)

func (*Importer) FindExistingID

func (i *Importer) FindExistingID(ctx context.Context) (*int, error)

func (*Importer) Name

func (i *Importer) Name() string

func (*Importer) PostImport

func (i *Importer) PostImport(ctx context.Context, id int) error

func (*Importer) PreImport

func (i *Importer) PreImport(ctx context.Context) error

func (*Importer) Update

func (i *Importer) Update(ctx context.Context, id int) error

type PartialUpdater added in v0.17.0

type PartialUpdater interface {
	UpdatePartial(ctx context.Context, id int, partial models.ImagePartial) (*models.Image, error)
}

type Queryer added in v0.11.0

type Queryer interface {
	Query(ctx context.Context, options models.ImageQueryOptions) (*models.ImageQueryResult, error)
}

type Repository added in v0.17.0

type Repository interface {
	FinderByFile
	Destroyer
	models.ImageFileLoader
}

type ScanConfig added in v0.17.0

type ScanConfig interface {
	GetCreateGalleriesFromFolders() bool
	IsGenerateThumbnails() bool
}

type ScanHandler added in v0.17.0

type ScanHandler struct {
	CreatorUpdater FinderCreatorUpdater
	GalleryFinder  GalleryFinderCreator

	ThumbnailGenerator ThumbnailGenerator

	ScanConfig ScanConfig

	PluginCache *plugin.Cache

	Paths *paths.Paths
}

func (*ScanHandler) Handle added in v0.17.0

func (h *ScanHandler) Handle(ctx context.Context, f file.File, oldFile file.File) error

type Service added in v0.17.0

type Service struct {
	File       file.Store
	Repository Repository
}

func (*Service) Destroy added in v0.17.0

func (s *Service) Destroy(ctx context.Context, i *models.Image, fileDeleter *FileDeleter, deleteGenerated, deleteFile bool) error

Destroy destroys an image, optionally marking the file and generated files for deletion.

func (*Service) DestroyZipImages added in v0.17.0

func (s *Service) DestroyZipImages(ctx context.Context, zipFile file.File, fileDeleter *FileDeleter, deleteGenerated bool) ([]*models.Image, error)

DestroyZipImages destroys all images in zip, optionally marking the files and generated files for deletion. Returns a slice of images that were destroyed.

type ThumbnailEncoder added in v0.10.0

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

func NewThumbnailEncoder added in v0.10.0

func NewThumbnailEncoder(ffmpegEncoder ffmpeg.FFMpeg) ThumbnailEncoder

func (*ThumbnailEncoder) GetThumbnail added in v0.10.0

func (e *ThumbnailEncoder) GetThumbnail(f *file.ImageFile, maxSize int) ([]byte, error)

GetThumbnail returns the thumbnail image of the provided image resized to the provided max size. It resizes based on the largest X/Y direction. It returns nil and an error if an error occurs reading, decoding or encoding the image, or if the image is not suitable for thumbnails.

type ThumbnailGenerator added in v0.17.0

type ThumbnailGenerator interface {
	GenerateThumbnail(ctx context.Context, i *models.Image, f *file.ImageFile) error
}

Jump to

Keyboard shortcuts

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