Documentation
¶
Index ¶
- func AddComicInfoToCBR(cbrPath string, comicInfoXML []byte) error
- func AddComicInfoToCBZ(cbzPath string, comicInfoXML []byte) error
- func CopyFile(src, dst string) error
- func CountImageFiles(archiveFilePath string) (int, error)
- func CountPagesInArchive(archivePath string) (int, error)
- func DecryptSlug(mediaSlug, chapterSlug, slug string) (slugType, librarySlug, value string, err error)
- func DownloadImageWithThumbnails(fileName, fileUrl string, dataBackend *store.FileStore, useWebp bool) error
- func DownloadPosterImage(imageURL, slug string, dataBackend *store.FileStore, useWebp bool) (string, error)
- func EncodeImageToBytes(img image.Image, format string, quality int) ([]byte, error)
- func ExtractAndStoreFirstImage(archivePath, slug, dataDir string, quality int) (string, error)
- func ExtractAndStoreImageWithCrop(imagePath string, slug string, cropData map[string]any, quality int, ...) (string, error)
- func ExtractAndStoreImageWithCropByIndex(mangaPath, slug string, imageIndex int, cropData map[string]any, useWebP bool, ...) (string, error)
- func ExtractFirstImage(archivePath, outputFolder string) error
- func ExtractPosterImage(filePath, slug string, dataBackend *store.FileStore, useWebp bool) (string, error)
- func ExtractTitle(html string) string
- func FindBestPreviewImage(chapterFilePath string) (image.Image, error)
- func GenerateAssetSlug(mediaSlug, librarySlug, chapterSlug, assetPath string) string
- func GenerateChapterPreview(chapterFilePath string) ([]byte, error)
- func GeneratePageSlug(mediaSlug, librarySlug, chapterSlug string, page int) string
- func GenerateRandomSecret() (string, error)
- func GenerateThumbnails(fullImagePath, slug string, dataBackend *store.FileStore) error
- func GetBookContent(epubPath, mangaSlug, librarySlug, chapterSlug string) string
- func GetDataDirectory() string
- func GetImageDataURIByIndex(mangaPath string, imageIndex int) (string, error)
- func GetMiddleImageDimensions(chapterPath string) (int, int, error)
- func GetOPFDir(epubPath string) (string, error)
- func GetTOC(epubPath string) string
- func GetTitlesFromNCX(epubPath string) (map[string]string, error)
- func IsWebtoonByAspectRatio(width, height int) bool
- func ListImagesInManga(mangaPath string) ([]string, error)
- func OpenImage(path string) (image.Image, error)
- func ProcessImage(fromPath, toPath string, quality int) error
- func ProcessImageWithCrop(fromPath, toPath string, cropData map[string]any, quality int) error
- func ProcessImageWithTopCrop(fromPath, toPath string, quality int) error
- func ProcessLocalImageWithThumbnails(imagePath, slug string, dataBackend *store.FileStore, useWebp bool) (string, error)
- func SaveImage(filePath string, img image.Image, format string, quality int) error
- func SetDataDirectory(dir string)
- func SetSlugKey(imageAccessSecret string)
- type ArchiveIterator
- type Chapter
- type ChapterPreviewResult
- type Container
- type GrayscaleImage
- type NCX
- type Package
- type ThumbnailSize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddComicInfoToCBR ¶ added in v1.12.0
AddComicInfoToCBR adds a ComicInfo.xml file to a CBR archive by converting it to CBZ format
func AddComicInfoToCBZ ¶ added in v1.12.0
AddComicInfoToCBZ adds a ComicInfo.xml file to an existing CBZ archive
func CountImageFiles ¶
CountImageFiles counts the number of image files in an archive (zip, cbz, rar, or cbr) or directory.
func CountPagesInArchive ¶ added in v1.12.0
CountPagesInArchive counts the number of image pages in a CBZ/CBR archive
func DecryptSlug ¶ added in v1.12.0
func DecryptSlug(mediaSlug, chapterSlug, slug string) (slugType, librarySlug, value string, err error)
DecryptSlug decrypts a slug and returns the type ("page" or "asset"), library slug, and value.
func DownloadImageWithThumbnails ¶
func DownloadImageWithThumbnails(fileName, fileUrl string, dataBackend *store.FileStore, useWebp bool) error
DownloadImageWithThumbnails downloads an image and creates multiple sizes for better performance
func DownloadPosterImage ¶ added in v1.12.0
func DownloadPosterImage(imageURL, slug string, dataBackend *store.FileStore, useWebp bool) (string, error)
DownloadPosterImage downloads an image from a URL and creates multiple cached sizes Creates: original, full (400x600), thumbnail (200x300), and small (100x150) versions Returns the URL path for the full-size image
func EncodeImageToBytes ¶
EncodeImageToBytes encodes an image to bytes in the specified format This is the base version without WebP support
func ExtractAndStoreFirstImage ¶
isImageFile checks if a file is an image based on its extension. ExtractAndStoreFirstImage extracts the first image from an archive and stores it with proper resizing. For tall images (webtoons), it crops from the top to capture the cover/title area. Returns the stored image URL path.
func ExtractAndStoreImageWithCrop ¶
func ExtractAndStoreImageWithCrop(imagePath string, slug string, cropData map[string]any, quality int, useWebP bool) (string, error)
ExtractAndStoreImageWithCrop extracts an image (from a file path or archive) and stores it with optional cropping. ExtractAndStoreImageWithCrop extracts an image (from a file path or archive) and stores it with optional cropping.
func ExtractAndStoreImageWithCropByIndex ¶
func ExtractAndStoreImageWithCropByIndex(mangaPath, slug string, imageIndex int, cropData map[string]any, useWebP bool, quality int) (string, error)
ExtractAndStoreImageWithCropByIndex extracts an image by index with cropping
func ExtractFirstImage ¶
ExtractFirstImage extracts the first image from an archive and saves it to the output folder.
func ExtractPosterImage ¶
func ExtractPosterImage(filePath, slug string, dataBackend *store.FileStore, useWebp bool) (string, error)
ExtractPosterImage extracts a poster-sized image from any supported file type (image or archive) and caches it with proper processing. For archives, it extracts the first image. For tall images (webtoons), it crops from the top to capture the cover/title area. Creates multiple sizes: original, full (400x600), thumbnail (200x300), and small (100x150). Returns the cached image URL path.
func ExtractTitle ¶
ExtractTitle extracts title from HTML content
func FindBestPreviewImage ¶ added in v1.13.0
FindBestPreviewImage analyzes pages and returns the decoded image of the best candidate.
func GenerateAssetSlug ¶ added in v1.12.0
GenerateAssetSlug creates a URL-safe slug that hides an EPUB asset path.
func GenerateChapterPreview ¶ added in v1.13.0
GenerateChapterPreview analyzes a chapter's images and returns a JPEG preview thumbnail from the most visually interesting page. It uses edge detection, color variance, and content density to find pages where "something is happening" rather than blank/title pages.
func GeneratePageSlug ¶ added in v1.12.0
GeneratePageSlug creates a URL-safe slug that hides the page number. The slug encodes the library slug + page number, XORed with an HMAC keystream and authenticated with an HMAC tag. Deterministic for the same inputs + key.
func GenerateRandomSecret ¶
GenerateRandomSecret generates a random 32-byte secret encoded as hex
func GenerateThumbnails ¶
GenerateThumbnails generates thumbnail and small versions from a cached full-size image
func GetBookContent ¶
GetBookContent extracts all readable content from an EPUB file as HTML
func GetDataDirectory ¶
func GetDataDirectory() string
GetDataDirectory returns the data directory path
func GetImageDataURIByIndex ¶
GetImageDataURIByIndex extracts an image at the given index and returns a data URI
func GetMiddleImageDimensions ¶
GetMiddleImageDimensions gets the width and height of the middle image in the first chapter. Returns width, height, and error.
func GetTitlesFromNCX ¶
GetTitlesFromNCX extracts titles from NCX navigation
func IsWebtoonByAspectRatio ¶
IsWebtoonByAspectRatio checks if an image's aspect ratio suggests it's a webtoon. Returns true if height is >= 3 times the width.
func ListImagesInManga ¶
ListImagesInManga returns a list of image paths/URIs from a manga file or directory. For directories, it returns the file paths of images. For archive files (.cbz, .cbr, .zip, .rar), it returns data URIs of the images.
func OpenImage ¶
openImage opens and decodes an image file. OpenImage opens and decodes an image from the given path
func ProcessImage ¶
ProcessImage processes an image by resizing and cropping it, then saving it to a new file.
func ProcessImageWithCrop ¶
ProcessImageWithCrop processes an image by applying user-defined cropping and resizing
func ProcessImageWithTopCrop ¶
ProcessImageWithTopCrop processes an image by extracting the top portion and resizing it. It takes the top square (or near-square) section of the image, useful for cover/poster areas.
func ProcessLocalImageWithThumbnails ¶
func ProcessLocalImageWithThumbnails(imagePath, slug string, dataBackend *store.FileStore, useWebp bool) (string, error)
ProcessLocalImageWithThumbnails processes a local image file and creates multiple cached sizes Creates: original, full (400x600), thumbnail (200x300), and small (100x150) versions Returns the URL path for the full-size image
func SaveImage ¶
saveImage encodes and saves an image to the specified path. SaveImage saves an image to the given path with the specified format and quality SaveImage saves an image to a file path with the specified format and quality
func SetDataDirectory ¶
func SetDataDirectory(dir string)
SetDataDirectory sets the data directory path
func SetSlugKey ¶ added in v1.12.0
func SetSlugKey(imageAccessSecret string)
SetSlugKey derives the slug HMAC key from the ImageAccessSecret. Call this once during startup after the DB config is loaded.
Types ¶
type ArchiveIterator ¶
type ArchiveIterator interface {
Next() (name string, reader io.ReadCloser, err error)
Close() error
}
ArchiveIterator provides a common interface for iterating through archive files
type Chapter ¶
EPUB parsing structures (from POC)
func GetChapters ¶
GetChapters extracts chapter information from an EPUB file
type ChapterPreviewResult ¶ added in v1.13.0
ChapterPreviewResult holds the analysis score and page index
type GrayscaleImage ¶ added in v1.13.0
GrayscaleImage is a simple grayscale image implementation
func (*GrayscaleImage) Bounds ¶ added in v1.13.0
func (g *GrayscaleImage) Bounds() image.Rectangle
func (*GrayscaleImage) ColorModel ¶ added in v1.13.0
func (g *GrayscaleImage) ColorModel() color.Model