Documentation ¶
Index ¶
- Constants
- Variables
- func MimetypeDetectorExtension(uri *url.URL) (string, error)
- func MimetypeDetectorFastimage(uri *url.URL) (string, error)
- func MimetypeDetectorSniff(uri *url.URL) (string, error)
- type Format
- type ImageFile
- func (i *ImageFile) Content() []byte
- func (i *ImageFile) ContentType() string
- func (i *ImageFile) Filename() string
- func (i *ImageFile) FilenameExt() string
- func (i *ImageFile) Format() string
- func (i *ImageFile) Path() string
- func (i *ImageFile) Save(ctx context.Context) error
- func (i *ImageFile) URL() string
- type MimetypeDetectorFunc
Constants ¶
View Source
const ( MimetypeDetectorTypeFastimage = "fastimage" MimetypeDetectorTypeSniff = "sniff" )
Variables ¶
View Source
var ( Extensions = map[string]string{ "image/bmp": "bmp", "image/gif": "gif", "image/jpeg": "jpg", "image/png": "png", "image/webp": "webp", } HeaderKeys = []string{ "Age", "Content-Type", "Date", "Etag", "Last-Modified", } )
Functions ¶
func MimetypeDetectorExtension ¶
Detect mimetype by looking at the URL extension
func MimetypeDetectorFastimage ¶
Detect mimetype with third-party fastimage library. Overhead warning: fastimage makes a request (albeit a very small partial one) upon each detection.
func MimetypeDetectorSniff ¶
Detect mimetype using go native content detection which implements the MIME Sniffing alorithm described here: https://mimesniff.spec.whatwg.org/
Types ¶
type ImageFile ¶
type ImageFile struct { Filepath string Headers map[string]string Key string Processed []byte Source []byte Storage *storage.Storage }
func FromStorage ¶
func FromStorage(ctx context.Context, storage *storagepkg.Storage, filepath string) (*ImageFile, error)
FromStorage retrieves an ImageFile from storage
func (*ImageFile) ContentType ¶
func (*ImageFile) FilenameExt ¶
type MimetypeDetectorFunc ¶
func GetMimetypeDetector ¶
func GetMimetypeDetector(mimetypeDetectorType string) MimetypeDetectorFunc
Click to show internal directories.
Click to hide internal directories.