Documentation
¶
Index ¶
- type ImageEngine
- func (e *ImageEngine) DetectByExtension(path string) bool
- func (e *ImageEngine) DetectByHeuristic(path string, header []byte) bool
- func (e *ImageEngine) DetectByMagic(header []byte) bool
- func (e *ImageEngine) Diff(ctx context.Context, oldPath string, oldReader io.Reader, newPath string, ...) (string, error)
- func (e *ImageEngine) Metadata() *core.FileMetadata
- func (e *ImageEngine) Name() string
- func (e *ImageEngine) Preview(header []byte, size int64, reader io.Reader, maxLines int) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImageEngine ¶
type ImageEngine struct {
chunker.DefaultSelector
}
ImageEngine handles image files (PNG, JPEG, GIF, WebP, BMP, TIFF).
func (*ImageEngine) DetectByExtension ¶
func (e *ImageEngine) DetectByExtension(path string) bool
DetectByExtension checks if the path's extension is a known image type.
func (*ImageEngine) DetectByHeuristic ¶
func (e *ImageEngine) DetectByHeuristic(path string, header []byte) bool
DetectByHeuristic returns false; images are not sniffed heuristically.
func (*ImageEngine) DetectByMagic ¶
func (e *ImageEngine) DetectByMagic(header []byte) bool
DetectByMagic checks file header signatures for known image magic bytes.
func (*ImageEngine) Diff ¶
func (e *ImageEngine) Diff(ctx context.Context, oldPath string, oldReader io.Reader, newPath string, newReader io.Reader) (string, error)
Diff compares two images streaming, without buffering either file wholly in memory. The leading core.HeaderPeekSize bytes are peeked for format and dimension detection; the remainder is hashed with BLAKE3 for an equality short-circuit. Priority of reported changes is:
format -> dimensions -> size -> content
Returns an empty string when the images are identical (same size and hash).
The full file bytes are never held in memory: only the fixed-size header buffer and the 32-byte hash digest are retained, so memory stays constant regardless of image size.
func (*ImageEngine) Metadata ¶
func (e *ImageEngine) Metadata() *core.FileMetadata
Metadata returns the file metadata for image files. The MIME type is a generic octet-stream placeholder; per-format refinement (image/png, etc.) is a future enhancement tracked separately.
func (*ImageEngine) Preview ¶
func (e *ImageEngine) Preview(header []byte, size int64, reader io.Reader, maxLines int) (string, error)
Preview returns a one-line summary: format name, dimensions, and human-readable file size (e.g. "PNG 1920x1080 2.4 MB").
Only the header is inspected (for magic detection and dimension parsing) and size is taken from the caller; the content reader is never touched. This keeps memory constant for arbitrarily large images. Dimension parsing delegates to format.DecodeDimensions so that PNG, JPEG, GIF, WebP, BMP, and TIFF are all supported.