mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-23 23:32:38 +02:00
add nocrop options
This commit is contained in:
parent
d9a8575898
commit
c6fec88582
@ -43,6 +43,7 @@ type EPub struct {
|
||||
ViewWidth int
|
||||
ViewHeight int
|
||||
Quality int
|
||||
Crop bool
|
||||
|
||||
Images []*Images
|
||||
FirstImageTitle string
|
||||
@ -92,6 +93,11 @@ func (e *EPub) SetQuality(q int) *EPub {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EPub) SetCrop(c bool) *EPub {
|
||||
e.Crop = c
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *EPub) WriteFile(wz *zip.Writer, file, content string) error {
|
||||
m, err := wz.CreateHeader(&zip.FileHeader{
|
||||
Name: file,
|
||||
@ -171,7 +177,7 @@ func (e *EPub) LoadDir(dirname string) *EPub {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for task := range todo {
|
||||
data, w, h := imageconverter.Convert(task.Path, true, e.ViewWidth, e.ViewHeight, e.Quality)
|
||||
data, w, h := imageconverter.Convert(task.Path, e.Crop, e.ViewWidth, e.ViewHeight, e.Quality)
|
||||
results <- &ImageDetails{task.Images, data, w, h}
|
||||
}
|
||||
}()
|
||||
|
5
main.go
5
main.go
@ -25,6 +25,7 @@ type Option struct {
|
||||
Author string
|
||||
Title string
|
||||
Quality int
|
||||
NoCrop bool
|
||||
}
|
||||
|
||||
func (o *Option) String() string {
|
||||
@ -43,6 +44,7 @@ func (o *Option) String() string {
|
||||
Author : %s
|
||||
Title : %s
|
||||
Quality: %d
|
||||
Crop : %v
|
||||
`,
|
||||
o.Input,
|
||||
o.Output,
|
||||
@ -53,6 +55,7 @@ func (o *Option) String() string {
|
||||
o.Author,
|
||||
o.Title,
|
||||
o.Quality,
|
||||
!o.NoCrop,
|
||||
)
|
||||
}
|
||||
|
||||
@ -69,6 +72,7 @@ func main() {
|
||||
flag.StringVar(&opt.Author, "author", "GO Comic Converter", "Author 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.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping: Default false")
|
||||
flag.Parse()
|
||||
|
||||
if opt.Input == "" || opt.Output == "" {
|
||||
@ -92,6 +96,7 @@ func main() {
|
||||
err := epub.NewEpub(opt.Output).
|
||||
SetSize(profile.Width, profile.Height).
|
||||
SetQuality(opt.Quality).
|
||||
SetCrop(!opt.NoCrop).
|
||||
SetTitle(opt.Title).
|
||||
SetAuthor(opt.Author).
|
||||
LoadDir(opt.Input).
|
||||
|
Loading…
x
Reference in New Issue
Block a user