image

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: AGPL-3.0 Imports: 25 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 models.ImageUpdater, i *models.Image, performerID int) error

func AddTag added in v0.7.0

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

func CountByPerformerID added in v0.7.0

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

func CountByStudioID added in v0.7.0

func CountByStudioID(ctx context.Context, r models.ImageQueryer, id int, depth *int) (int, error)

func CountByTagID added in v0.7.0

func CountByTagID(ctx context.Context, r models.ImageQueryer, id int, depth *int) (int, error)

func FindByGalleryID added in v0.14.0

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

func FindGalleryCover added in v0.18.0

func FindGalleryCover(ctx context.Context, r models.ImageQueryer, galleryID int, galleryCoverRegex string) (*models.Image, error)

func GetStudioName

func GetStudioName(ctx context.Context, reader models.StudioGetter, 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 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 models.ImageQueryer, 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 ClipPreviewOptions added in v0.21.0

type ClipPreviewOptions struct {
	InputArgs  []string
	OutputArgs []string
	Preset     string
}

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 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 models.FileID) ([]*models.Gallery, error)
	FindByFolderID(ctx context.Context, folderID models.FolderID) ([]*models.Gallery, error)
	Create(ctx context.Context, newObject *models.Gallery, fileIDs []models.FileID) error
	UpdatePartial(ctx context.Context, id int, updatedGallery models.GalleryPartial) (*models.Gallery, error)
}

type Importer

type Importer struct {
	ReaderWriter        ImporterReaderWriter
	FileFinder          models.FileFinder
	StudioWriter        models.StudioFinderCreator
	GalleryFinder       GalleryFinder
	PerformerWriter     models.PerformerFinderCreator
	TagWriter           models.TagFinderCreator
	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 ImporterReaderWriter added in v0.23.0

type ImporterReaderWriter interface {
	models.ImageCreatorUpdater
	FindByFileID(ctx context.Context, fileID models.FileID) ([]*models.Image, error)
}

type ScanConfig added in v0.17.0

type ScanConfig interface {
	GetCreateGalleriesFromFolders() bool
}

type ScanCreatorUpdater added in v0.23.0

type ScanCreatorUpdater interface {
	FindByFileID(ctx context.Context, fileID models.FileID) ([]*models.Image, error)
	FindByFolderID(ctx context.Context, folderID models.FolderID) ([]*models.Image, error)
	FindByFingerprints(ctx context.Context, fp []models.Fingerprint) ([]*models.Image, error)
	GetFiles(ctx context.Context, relatedID int) ([]models.File, error)
	GetGalleryIDs(ctx context.Context, relatedID int) ([]int, error)

	Create(ctx context.Context, newImage *models.Image, fileIDs []models.FileID) error
	UpdatePartial(ctx context.Context, id int, updatedImage models.ImagePartial) (*models.Image, error)
	AddFileID(ctx context.Context, id int, fileID models.FileID) error
}

type ScanGenerator added in v0.21.0

type ScanGenerator interface {
	Generate(ctx context.Context, i *models.Image, f models.File) error
}

type ScanHandler added in v0.17.0

type ScanHandler struct {
	CreatorUpdater ScanCreatorUpdater
	GalleryFinder  GalleryFinderCreator

	ScanGenerator ScanGenerator

	ScanConfig ScanConfig

	PluginCache *plugin.Cache

	Paths *paths.Paths
}

func (*ScanHandler) Handle added in v0.17.0

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

type Service added in v0.17.0

type Service struct {
	File       models.FileReaderWriter
	Repository models.ImageReaderWriter
}

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 models.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 {
	FFMpeg             *ffmpeg.FFMpeg
	FFProbe            ffmpeg.FFProbe
	ClipPreviewOptions ClipPreviewOptions
	// contains filtered or unexported fields
}

func NewThumbnailEncoder added in v0.10.0

func NewThumbnailEncoder(ffmpegEncoder *ffmpeg.FFMpeg, ffProbe ffmpeg.FFProbe, clipPreviewOptions ClipPreviewOptions) ThumbnailEncoder

func (*ThumbnailEncoder) GetPreview added in v0.21.0

func (e *ThumbnailEncoder) GetPreview(inPath string, outPath string, maxSize int) error

GetPreview returns the preview clip of the provided image clip resized to the provided max size. It resizes based on the largest X/Y direction. It is hardcoded to 30 seconds maximum right now

func (*ThumbnailEncoder) GetThumbnail added in v0.10.0

func (e *ThumbnailEncoder) GetThumbnail(f models.File, 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.

Jump to

Keyboard shortcuts

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