Documentation
¶
Index ¶
- type DefaultImageProcessor
- func (p *DefaultImageProcessor) CreateThumbnail(sourcePath, outputPath string, maxWidth, maxHeight int) error
- func (p *DefaultImageProcessor) DecodeImage(r io.Reader) (image.Image, string, error)
- func (p *DefaultImageProcessor) EncodeImage(w io.Writer, img image.Image, format string) error
- func (p *DefaultImageProcessor) ResizeImage(src image.Image, width, height uint) image.Image
- type DefaultMediaDetector
- type DefaultThumbnailGenerator
- func (g *DefaultThumbnailGenerator) ClearCache() error
- func (g *DefaultThumbnailGenerator) GenerateThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
- func (g *DefaultThumbnailGenerator) GenerateVideoThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
- func (g *DefaultThumbnailGenerator) GetCachedThumbnail(filePath string, maxWidth, maxHeight int) (string, bool)
- type ImageProcessor
- type Manager
- func (m *Manager) Cleanup() error
- func (m *Manager) GenerateThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
- func (m *Manager) GetCacheDir() string
- func (m *Manager) GetMediaInfo(filePath string) (*MediaInfo, error)
- func (m *Manager) GetMediaTypeString(filePath string) string
- func (m *Manager) GetSupportedImageFormats() []string
- func (m *Manager) GetSupportedVideoFormats() []string
- func (m *Manager) GetThumbnailPath(filePath string, maxWidth, maxHeight int) (string, bool)
- func (m *Manager) IsImageFile(filePath string) bool
- func (m *Manager) IsMediaFile(filePath string) bool
- func (m *Manager) IsVideoFile(filePath string) bool
- func (m *Manager) SetCacheDir(cacheDir string)
- func (m *Manager) ValidateFile(filePath string) error
- type ManagerInterface
- type MediaDetector
- type MediaInfo
- type MediaType
- type ThumbnailGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultImageProcessor ¶
type DefaultImageProcessor struct{}
DefaultImageProcessor implements ImageProcessor using standard libraries
func NewDefaultImageProcessor ¶
func NewDefaultImageProcessor() *DefaultImageProcessor
NewDefaultImageProcessor creates a new image processor
func (*DefaultImageProcessor) CreateThumbnail ¶
func (p *DefaultImageProcessor) CreateThumbnail(sourcePath, outputPath string, maxWidth, maxHeight int) error
CreateThumbnail creates a thumbnail from an image file
func (*DefaultImageProcessor) DecodeImage ¶
DecodeImage decodes an image from a reader and returns the image and format
func (*DefaultImageProcessor) EncodeImage ¶
EncodeImage encodes an image to the specified format
func (*DefaultImageProcessor) ResizeImage ¶
ResizeImage resizes an image to the specified dimensions while maintaining aspect ratio
type DefaultMediaDetector ¶
type DefaultMediaDetector struct{}
DefaultMediaDetector implements MediaDetector using file analysis
func NewDefaultMediaDetector ¶
func NewDefaultMediaDetector() *DefaultMediaDetector
NewDefaultMediaDetector creates a new media detector
func (*DefaultMediaDetector) DetectMediaType ¶
func (d *DefaultMediaDetector) DetectMediaType(filePath string) (MediaType, error)
DetectMediaType determines the media type from file extension and content
func (*DefaultMediaDetector) GetMediaInfo ¶
func (d *DefaultMediaDetector) GetMediaInfo(filePath string) (*MediaInfo, error)
GetMediaInfo extracts comprehensive information about a media file
func (*DefaultMediaDetector) IsSupported ¶
func (d *DefaultMediaDetector) IsSupported(filePath string) bool
IsSupported checks if the file type is supported for preview
type DefaultThumbnailGenerator ¶
type DefaultThumbnailGenerator struct {
// contains filtered or unexported fields
}
DefaultThumbnailGenerator implements ThumbnailGenerator with file-based caching
func NewDefaultThumbnailGenerator ¶
func NewDefaultThumbnailGenerator(cacheDir string, processor ImageProcessor) *DefaultThumbnailGenerator
NewDefaultThumbnailGenerator creates a new thumbnail generator
func (*DefaultThumbnailGenerator) ClearCache ¶
func (g *DefaultThumbnailGenerator) ClearCache() error
ClearCache removes all cached thumbnails
func (*DefaultThumbnailGenerator) GenerateThumbnail ¶
func (g *DefaultThumbnailGenerator) GenerateThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
GenerateThumbnail creates a thumbnail for the given file and returns the thumbnail path
func (*DefaultThumbnailGenerator) GenerateVideoThumbnail ¶
func (g *DefaultThumbnailGenerator) GenerateVideoThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
GenerateVideoThumbnail creates a thumbnail for video files
func (*DefaultThumbnailGenerator) GetCachedThumbnail ¶
func (g *DefaultThumbnailGenerator) GetCachedThumbnail(filePath string, maxWidth, maxHeight int) (string, bool)
GetCachedThumbnail returns the cached thumbnail path if it exists
type ImageProcessor ¶
type ImageProcessor interface {
// ResizeImage resizes an image to the specified dimensions
ResizeImage(src image.Image, width, height uint) image.Image
// DecodeImage decodes an image from a reader
DecodeImage(r io.Reader) (image.Image, string, error)
// EncodeImage encodes an image to the specified format
EncodeImage(w io.Writer, img image.Image, format string) error
// CreateThumbnail creates a thumbnail from an image file
CreateThumbnail(sourcePath, outputPath string, maxWidth, maxHeight int) error
}
ImageProcessor processes images for thumbnails and previews
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates all media-related operations
func NewManager ¶
NewManager creates a new media manager with all components
func (*Manager) GenerateThumbnail ¶
GenerateThumbnail creates a thumbnail for a media file
func (*Manager) GetCacheDir ¶
GetCacheDir returns the cache directory path
func (*Manager) GetMediaInfo ¶
GetMediaInfo returns information about a media file
func (*Manager) GetMediaTypeString ¶
GetMediaTypeString returns a human-readable media type string
func (*Manager) GetSupportedImageFormats ¶
GetSupportedImageFormats returns a list of supported image formats
func (*Manager) GetSupportedVideoFormats ¶
GetSupportedVideoFormats returns a list of supported video formats
func (*Manager) GetThumbnailPath ¶
GetThumbnailPath returns the thumbnail path for a file
func (*Manager) IsImageFile ¶
IsImageFile checks if the file is an image
func (*Manager) IsMediaFile ¶
IsMediaFile checks if the file is a supported media type
func (*Manager) IsVideoFile ¶
IsVideoFile checks if the file is a video
func (*Manager) SetCacheDir ¶
SetCacheDir updates the cache directory (useful for configuration changes)
func (*Manager) ValidateFile ¶
ValidateFile checks if a file exists and is accessible
type ManagerInterface ¶
type ManagerInterface interface {
// GetMediaInfo returns information about a media file
GetMediaInfo(filePath string) (*MediaInfo, error)
// GenerateThumbnail creates a thumbnail for a media file
GenerateThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
// IsMediaFile checks if the file is a supported media type
IsMediaFile(filePath string) bool
// GetThumbnailPath returns the thumbnail path for a file
GetThumbnailPath(filePath string, maxWidth, maxHeight int) (string, bool)
// Cleanup removes cached thumbnails
Cleanup() error
}
ManagerInterface defines the public interface for the media manager
type MediaDetector ¶
type MediaDetector interface {
// DetectMediaType determines the media type from file extension and content
DetectMediaType(filePath string) (MediaType, error)
// GetMediaInfo extracts comprehensive information about a media file
GetMediaInfo(filePath string) (*MediaInfo, error)
// IsSupported checks if the file type is supported for preview
IsSupported(filePath string) bool
}
MediaDetector detects media file types and properties
type MediaInfo ¶
type MediaInfo struct {
Type MediaType `json:"type"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"` // in seconds for video/audio
Size int64 `json:"size"` // file size in bytes
MimeType string `json:"mime_type"`
ThumbnailPath string `json:"thumbnail_path,omitempty"`
}
MediaInfo contains information about a media file
type ThumbnailGenerator ¶
type ThumbnailGenerator interface {
// GenerateThumbnail creates a thumbnail for the given file and returns the thumbnail path
GenerateThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
// GenerateVideoThumbnail creates a thumbnail for video files
GenerateVideoThumbnail(filePath string, maxWidth, maxHeight int) (string, error)
// GetCachedThumbnail returns the cached thumbnail path if it exists
GetCachedThumbnail(filePath string, maxWidth, maxHeight int) (string, bool)
// ClearCache removes all cached thumbnails
ClearCache() error
}
ThumbnailGenerator generates thumbnails for media files