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
|
ViewHeight int
|
||||||
Quality int
|
Quality int
|
||||||
Crop bool
|
Crop bool
|
||||||
|
LimitMb int
|
||||||
|
|
||||||
Images []*Images
|
Images []*Images
|
||||||
FirstImageTitle string
|
FirstImageTitle string
|
||||||
@ -99,6 +100,11 @@ func (e *EPub) SetCrop(c bool) *EPub {
|
|||||||
return e
|
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 {
|
func (e *EPub) WriteString(wz *zip.Writer, file string, content string) error {
|
||||||
return e.WriteBuffer(wz, file, strings.NewReader(content))
|
return e.WriteBuffer(wz, file, strings.NewReader(content))
|
||||||
}
|
}
|
||||||
|
22
main.go
22
main.go
@ -26,6 +26,7 @@ type Option struct {
|
|||||||
Title string
|
Title string
|
||||||
Quality int
|
Quality int
|
||||||
NoCrop bool
|
NoCrop bool
|
||||||
|
LimitMb int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Option) String() string {
|
func (o *Option) String() string {
|
||||||
@ -36,15 +37,20 @@ func (o *Option) String() string {
|
|||||||
width = profile.Width
|
width = profile.Width
|
||||||
height = profile.Height
|
height = profile.Height
|
||||||
}
|
}
|
||||||
|
limitmb := "nolimit"
|
||||||
|
if o.LimitMb > 0 {
|
||||||
|
limitmb = fmt.Sprintf("%d Mb", o.LimitMb)
|
||||||
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(`Options:
|
return fmt.Sprintf(`Options:
|
||||||
Input : %s
|
Input : %s
|
||||||
Output : %s
|
Output : %s
|
||||||
Profile: %s - %s - %dx%d
|
Profile: %s - %s - %dx%d
|
||||||
Author : %s
|
Author : %s
|
||||||
Title : %s
|
Title : %s
|
||||||
Quality: %d
|
Quality: %d
|
||||||
Crop : %v
|
Crop : %v
|
||||||
|
LimitMb: %s
|
||||||
`,
|
`,
|
||||||
o.Input,
|
o.Input,
|
||||||
o.Output,
|
o.Output,
|
||||||
@ -56,6 +62,7 @@ func (o *Option) String() string {
|
|||||||
o.Title,
|
o.Title,
|
||||||
o.Quality,
|
o.Quality,
|
||||||
!o.NoCrop,
|
!o.NoCrop,
|
||||||
|
limitmb,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +80,7 @@ func main() {
|
|||||||
flag.StringVar(&opt.Title, "title", "", "Title of the epub")
|
flag.StringVar(&opt.Title, "title", "", "Title of the epub")
|
||||||
flag.IntVar(&opt.Quality, "quality", 85, "Quality of the image: Default 75")
|
flag.IntVar(&opt.Quality, "quality", 85, "Quality of the image: Default 75")
|
||||||
flag.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping: Default false")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
if opt.Input == "" || opt.Output == "" {
|
if opt.Input == "" || opt.Output == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user