Documentation
¶
Index ¶
- Constants
- func GetFmtBasename(basename, format string) string
- func GetImagesFromDir(dirname string) ([]string, error)
- func HumDS2Bytes(size string) (len uint64, err error)
- func HumDSLimit(size string, limit string) (bool, error)
- type Category
- type Error
- type Filter
- type Image
- type LocImage
- type Setting
- type Task
- func (gt *Task) Add(image Image) *Task
- func (gt *Task) AddImg(img string) *Task
- func (gt *Task) AddImgs(imgs string) *Task
- func (gt *Task) AddScanDir(dir string) *Task
- func (gt *Task) AddUrl(url string) *Task
- func (gt *Task) AddUrls(urls string) *Task
- func (gt *Task) EmptyTask() bool
- func (gt *Task) Filter(image Image) error
- func (gt *Task) Report()
- func (gt *Task) Run()
- func (gt *Task) SetFilter(f *Filter) *Task
- func (gt *Task) SetVerbose(v bool) *Task
- type WebImage
Constants ¶
const ( // input extract ErrGetLocalDirImages = 21 ErrOpenLocalImage = 22 ErrOpenHttpImage = 23 // filter ErrDetectName = 30 ErrDetectSize = 31 // resize handle ErrResize = 40 )
Resize Error
const ( M byteSize G T P )
Growth based on human-readable unit formats, 1k=1024b,1M=1024k..
Variables ¶
This section is empty.
Functions ¶
func GetFmtBasename ¶
GetFmtBasename get the new image basename based on the specified target image format and the name of the original image
func GetImagesFromDir ¶
GetImagesFromDir gets slice of the image file and iterates through the selected directory and its subdirectories.
func HumDS2Bytes ¶
HumDS2Bytes parse human data size(like 10k,10M) to bytes unit length, like 1k = 1024bytes
func HumDSLimit ¶
HumDSLimit compare human data sizes and limit setting (like find -size). Param size and limit both support human data size format(bytes, kilobytes, megabytes), like 100k, 1M
HumDSLimit("2000", "+1k") represent whether 1000 bytes >= 1*1024 bytes
+/-: >= or < , 1k: 1k=1024bytes
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is an filter pick up the image matching the condition
func (*Filter) DetectName ¶
DetectName check the input url or image file whether match the filter pattern
type Image ¶
type Image interface { // SetResize set image resizing setting property, used for image resize SetResize(setting *Setting) // DoResize fit the specified resizing configuration resize image to destination // Fit the specified scaling configuration (such as size, interpolation function, path, quality), // perform image scaling, return the path of the scaled image, or any errors in the scaling process DoResize() (string, error) }
Image support using specified parameters resize image to dst
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task used for collect image resize, dispatching resize image task, got the save result or fail info from channel
func (*Task) Add ¶
Add use filtering information to filter files, and add image to task for resizing
func (*Task) AddScanDir ¶
AddDirname specified dirname, scan images and add it to gir task, waiting for resize
func (*Task) Report ¶
func (gt *Task) Report()
Report synchronously report success or fail result in background, when gir task is finish
func (*Task) Run ¶
func (gt *Task) Run()
ResizeImages concurrency resize image in it's GirImage slice
func (*Task) SetVerbose ¶
SetVerbose setting the task show detail message