mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-24 07:42:37 +02:00
add limit option
This commit is contained in:
parent
0ee44ed40b
commit
95eb3497e7
@ -45,6 +45,7 @@ type EPub struct {
|
||||
ViewHeight int
|
||||
Quality int
|
||||
Crop bool
|
||||
LimitMb int
|
||||
|
||||
Images []*Images
|
||||
FirstImageTitle string
|
||||
@ -99,6 +100,11 @@ func (e *EPub) SetCrop(c bool) *EPub {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EPub) SetLimitMb(l int) *EPub {
|
||||
e.LimitMb = l
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EPub) WriteString(wz *zip.Writer, file string, content string) error {
|
||||
return e.WriteBuffer(wz, file, strings.NewReader(content))
|
||||
}
|
||||
|
8
main.go
8
main.go
@ -26,6 +26,7 @@ type Option struct {
|
||||
Title string
|
||||
Quality int
|
||||
NoCrop bool
|
||||
LimitMb int
|
||||
}
|
||||
|
||||
func (o *Option) String() string {
|
||||
@ -36,6 +37,10 @@ func (o *Option) String() string {
|
||||
width = profile.Width
|
||||
height = profile.Height
|
||||
}
|
||||
limitmb := "nolimit"
|
||||
if o.LimitMb > 0 {
|
||||
limitmb = fmt.Sprintf("%d Mb", o.LimitMb)
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`Options:
|
||||
Input : %s
|
||||
@ -45,6 +50,7 @@ func (o *Option) String() string {
|
||||
Title : %s
|
||||
Quality: %d
|
||||
Crop : %v
|
||||
LimitMb: %s
|
||||
`,
|
||||
o.Input,
|
||||
o.Output,
|
||||
@ -56,6 +62,7 @@ func (o *Option) String() string {
|
||||
o.Title,
|
||||
o.Quality,
|
||||
!o.NoCrop,
|
||||
limitmb,
|
||||
)
|
||||
}
|
||||
|
||||
@ -73,6 +80,7 @@ func main() {
|
||||
flag.StringVar(&opt.Title, "title", "", "Title of the epub")
|
||||
flag.IntVar(&opt.Quality, "quality", 85, "Quality of the image: Default 75")
|
||||
flag.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping: Default false")
|
||||
flag.IntVar(&opt.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit")
|
||||
flag.Parse()
|
||||
|
||||
if opt.Input == "" || opt.Output == "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user