mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
add brightness and contrast
This commit is contained in:
parent
e8c028d276
commit
8475faa648
@ -76,10 +76,12 @@ The ePub include as a first page:
|
|||||||
# go-comic-converter -h
|
# go-comic-converter -h
|
||||||
|
|
||||||
Usage of go-comic-converter:
|
Usage of go-comic-converter:
|
||||||
-algo string
|
|
||||||
Algo for RGB to Grayscale: default, mean, luma, luster (default "default")
|
|
||||||
-author string
|
-author string
|
||||||
Author of the epub (default "GO Comic Converter")
|
Author of the epub (default "GO Comic Converter")
|
||||||
|
-brightness int
|
||||||
|
Brightness readjustement: between -100 and 100, > 0 lighter, < 0 darker
|
||||||
|
-contrast int
|
||||||
|
Contrast readjustement: between -100 and 100, > 0 more contrast, < 0 less contrast
|
||||||
-input string
|
-input string
|
||||||
Source of comic to convert: directory, cbz, zip, cbr, rar, pdf
|
Source of comic to convert: directory, cbz, zip, cbr, rar, pdf
|
||||||
-limitmb int
|
-limitmb int
|
||||||
|
@ -18,6 +18,8 @@ type ImageOptions struct {
|
|||||||
Quality int
|
Quality int
|
||||||
Algo string
|
Algo string
|
||||||
Palette color.Palette
|
Palette color.Palette
|
||||||
|
Brightness int
|
||||||
|
Contrast int
|
||||||
}
|
}
|
||||||
|
|
||||||
type EpubOptions struct {
|
type EpubOptions struct {
|
||||||
|
@ -139,9 +139,9 @@ func LoadImages(path string, options *ImageOptions) ([]*Image, error) {
|
|||||||
// prepare filter
|
// prepare filter
|
||||||
g := gift.New(
|
g := gift.New(
|
||||||
gift.Crop(findMarging(src)),
|
gift.Crop(findMarging(src)),
|
||||||
|
gift.Contrast(float32(options.Contrast)),
|
||||||
|
gift.Brightness(float32(options.Brightness)),
|
||||||
gift.ResizeToFit(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
|
gift.ResizeToFit(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
|
||||||
// gift.Gamma(1.8),
|
|
||||||
// gift.Sigmoid(0.5, 5),
|
|
||||||
)
|
)
|
||||||
g.SetParallelization(false)
|
g.SetParallelization(false)
|
||||||
|
|
||||||
|
22
main.go
22
main.go
@ -63,6 +63,8 @@ type Option struct {
|
|||||||
Title string
|
Title string
|
||||||
Quality int
|
Quality int
|
||||||
NoCrop bool
|
NoCrop bool
|
||||||
|
Brightness int
|
||||||
|
Contrast int
|
||||||
LimitMb int
|
LimitMb int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +93,8 @@ Options:
|
|||||||
Title : %s
|
Title : %s
|
||||||
Quality : %d
|
Quality : %d
|
||||||
Crop : %v
|
Crop : %v
|
||||||
|
Brightness: %d
|
||||||
|
Contrast : %d
|
||||||
LimitMb : %s
|
LimitMb : %s
|
||||||
`,
|
`,
|
||||||
o.Input,
|
o.Input,
|
||||||
@ -100,6 +104,8 @@ Options:
|
|||||||
o.Title,
|
o.Title,
|
||||||
o.Quality,
|
o.Quality,
|
||||||
!o.NoCrop,
|
!o.NoCrop,
|
||||||
|
o.Brightness,
|
||||||
|
o.Contrast,
|
||||||
limitmb,
|
limitmb,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -124,6 +130,8 @@ 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")
|
flag.IntVar(&opt.Quality, "quality", 85, "Quality of the image")
|
||||||
flag.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping")
|
flag.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping")
|
||||||
|
flag.IntVar(&opt.Brightness, "brightness", 0, "Brightness readjustement: between -100 and 100, > 0 lighter, < 0 darker")
|
||||||
|
flag.IntVar(&opt.Contrast, "contrast", 0, "Contrast readjustement: between -100 and 100, > 0 more contrast, < 0 less contrast")
|
||||||
flag.IntVar(&opt.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
flag.IntVar(&opt.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", filepath.Base(os.Args[0]))
|
fmt.Fprintf(os.Stderr, "Usage of %s:\n", filepath.Base(os.Args[0]))
|
||||||
@ -188,6 +196,18 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opt.Brightness < -100 || opt.Brightness > 100 {
|
||||||
|
fmt.Fprintln(os.Stderr, "Brightness should be between -100 and 100")
|
||||||
|
flag.Usage()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if opt.Contrast < -100 || opt.Contrast > 100 {
|
||||||
|
fmt.Fprintln(os.Stderr, "Contrast should be between -100 and 100")
|
||||||
|
flag.Usage()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if opt.Title == "" {
|
if opt.Title == "" {
|
||||||
ext := filepath.Ext(defaultOutput)
|
ext := filepath.Ext(defaultOutput)
|
||||||
opt.Title = filepath.Base(defaultOutput[0 : len(defaultOutput)-len(ext)])
|
opt.Title = filepath.Base(defaultOutput[0 : len(defaultOutput)-len(ext)])
|
||||||
@ -207,6 +227,8 @@ func main() {
|
|||||||
Quality: opt.Quality,
|
Quality: opt.Quality,
|
||||||
Crop: !opt.NoCrop,
|
Crop: !opt.NoCrop,
|
||||||
Palette: profile.Palette,
|
Palette: profile.Palette,
|
||||||
|
Brightness: opt.Brightness,
|
||||||
|
Contrast: opt.Contrast,
|
||||||
},
|
},
|
||||||
}).Write(); err != nil {
|
}).Write(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user