Documentation
¶
Index ¶
- Variables
- func AvailablePreview(file iteminfo.ExtendedFileInfo) bool
- func CacheKey(realPath, previewSize string, modTime time.Time, percentage int) string
- func CheckValidFFmpeg(path string) (string, error)
- func CheckValidFFprobe(path string) (string, error)
- func CreateThumbnail(rawData io.Reader, width, height int) (image.Image, error)
- func DelThumbs(ctx context.Context, file iteminfo.ExtendedFileInfo)
- func GeneratePreview(file iteminfo.ExtendedFileInfo, previewSize, officeUrl string, ...) ([]byte, error)
- func GetPreviewForFile(file iteminfo.ExtendedFileInfo, previewSize, url string, seekPercentage int) ([]byte, error)
- func StartPreviewGenerator(concurrencyLimit int, ffmpegPath, cacheDir string) error
- type Format
- type Option
- type Quality
- type ResizeMode
- type Service
- func (s *Service) CreatePreview(data []byte, previewSize string) ([]byte, error)
- func (s *Service) FormatFromExtension(ext string) (Format, error)
- func (s *Service) GenerateImageFromDoc(file iteminfo.ExtendedFileInfo, tempFilePath string, pageNumber int) ([]byte, error)
- func (s *Service) GenerateOfficePreview(filetype, key, title, url string) ([]byte, error)
- func (s *Service) GenerateVideoPreview(videoPath, outputPath string, percentageSeek int) ([]byte, error)
- func (s *Service) Resize(in io.Reader, width, height int, out io.Writer, options ...Option) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedFormat = errors.New("preview is not available for provided file format") ErrUnsupportedMedia = errors.New("unsupported media type") )
Functions ¶
func AvailablePreview ¶
func AvailablePreview(file iteminfo.ExtendedFileInfo) bool
func CheckValidFFmpeg ¶
CheckValidFFmpeg checks for a valid ffmpeg executable. If a path is provided, it looks there. Otherwise, it searches the system's PATH.
func CheckValidFFprobe ¶
CheckValidFFprobe checks for a valid ffprobe executable. If a path is provided, it looks there. Otherwise, it searches the system's PATH.
func CreateThumbnail ¶
CreateThumbnail decodes an image and creates a fixed-size thumbnail.
func GeneratePreview ¶
func GetPreviewForFile ¶
func StartPreviewGenerator ¶
Types ¶
type Format ¶
type Format int
Format is an image file format.
ENUM( jpeg png gif tiff bmp )
func ParseFormat ¶
ParseFormat attempts to convert a string to a Format
func (Format) MarshalText ¶
MarshalText implements the text marshaller method
func (*Format) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method
type Option ¶
type Option func(*resizeConfig)
func WithFormat ¶
func WithMode ¶
func WithMode(mode ResizeMode) Option
func WithQuality ¶
type Quality ¶
type Quality int
ENUM( high medium low )
func ParseQuality ¶
ParseQuality attempts to convert a string to a Quality
func (Quality) MarshalText ¶
MarshalText implements the text marshaller method
func (*Quality) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method
type ResizeMode ¶
type ResizeMode int
ENUM( fit fill )
const ( // ResizeModeFit is a ResizeMode of type Fit ResizeModeFit ResizeMode = iota // ResizeModeFill is a ResizeMode of type Fill ResizeModeFill )
func ParseResizeMode ¶
func ParseResizeMode(name string) (ResizeMode, error)
ParseResizeMode attempts to convert a string to a ResizeMode
func (ResizeMode) MarshalText ¶
func (x ResizeMode) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method
func (*ResizeMode) Scan ¶
func (x *ResizeMode) Scan(value interface{}) error
Scan implements the Scanner interface.
func (ResizeMode) String ¶
func (x ResizeMode) String() string
String implements the Stringer interface.
func (*ResizeMode) UnmarshalText ¶
func (x *ResizeMode) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewPreviewGenerator ¶
func (*Service) CreatePreview ¶
func (*Service) FormatFromExtension ¶
func (*Service) GenerateImageFromDoc ¶
func (*Service) GenerateOfficePreview ¶
GenerateOfficePreview generates a preview for an office document using OnlyOffice.
func (*Service) GenerateVideoPreview ¶
func (s *Service) GenerateVideoPreview(videoPath, outputPath string, percentageSeek int) ([]byte, error)
GenerateVideoPreview generates a single preview image from a video using ffmpeg. videoPath: path to the input video file. outputPath: path where the generated preview image will be saved (e.g., "/tmp/preview.jpg"). seekTime: how many seconds into the video to seek before capturing the frame.