mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
option to keep skip resize filter
This commit is contained in:
parent
13103b0eba
commit
ee00ed2615
@ -120,6 +120,7 @@ func (c *Converter) InitParse() {
|
||||
c.AddIntParam(&c.Options.SortPathMode, "sort", c.Options.SortPathMode, "Sort path mode\n0 = alpha for path and file\n1 = alphanum for path and alpha for file\n2 = alphanum for path and file")
|
||||
c.AddStringParam(&c.Options.ForegroundColor, "foreground-color", c.Options.ForegroundColor, "Foreground color in hexa format RGB. Black=000, White=FFF")
|
||||
c.AddStringParam(&c.Options.BackgroundColor, "background-color", c.Options.BackgroundColor, "Background color in hexa format RGB. Black=000, White=FFF, Light Gray=DDD, Dark Gray=777")
|
||||
c.AddBoolParam(&c.Options.NoResize, "noresize", c.Options.NoResize, "Do not reduce image size if exceed device size")
|
||||
|
||||
c.AddSection("Default config")
|
||||
c.AddBoolParam(&c.Options.Show, "show", false, "Show your default parameters")
|
||||
|
@ -42,6 +42,7 @@ type Options struct {
|
||||
SortPathMode int `yaml:"sort_path_mode"`
|
||||
ForegroundColor string `yaml:"foreground_color"`
|
||||
BackgroundColor string `yaml:"background_color"`
|
||||
NoResize bool `yaml:"noresize"`
|
||||
|
||||
// Default Config
|
||||
Show bool `yaml:"-"`
|
||||
@ -83,6 +84,7 @@ func New() *Options {
|
||||
SortPathMode: 1,
|
||||
ForegroundColor: "000",
|
||||
BackgroundColor: "FFF",
|
||||
NoResize: false,
|
||||
profiles: profiles.New(),
|
||||
}
|
||||
}
|
||||
@ -191,6 +193,7 @@ func (o *Options) ShowConfig() string {
|
||||
{"SortPathMode", sortpathmode},
|
||||
{"Foreground Color", fmt.Sprintf("#%s", o.ForegroundColor)},
|
||||
{"Background Color", fmt.Sprintf("#%s", o.BackgroundColor)},
|
||||
{"Resize", !o.NoResize},
|
||||
} {
|
||||
b.WriteString(fmt.Sprintf("\n %-26s: %v", v.K, v.V))
|
||||
}
|
||||
|
@ -201,10 +201,12 @@ func (e *EPUBImageProcessor) transformImage(src image.Image, srcId int) []image.
|
||||
splitFilter = append(splitFilter, f)
|
||||
}
|
||||
|
||||
filters = append(filters,
|
||||
gift.ResizeToFit(e.Image.View.Width, e.Image.View.Height, gift.LanczosResampling),
|
||||
epubimagefilters.Pixel(),
|
||||
)
|
||||
if e.Image.Resize {
|
||||
f := gift.ResizeToFit(e.Image.View.Width, e.Image.View.Height, gift.LanczosResampling)
|
||||
filters = append(filters, f)
|
||||
}
|
||||
|
||||
filters = append(filters, epubimagefilters.Pixel())
|
||||
|
||||
// convert
|
||||
{
|
||||
@ -232,10 +234,10 @@ func (e *EPUBImageProcessor) transformImage(src image.Image, srcId int) []image.
|
||||
// convert double page
|
||||
for _, b := range []bool{e.Image.Manga, !e.Image.Manga} {
|
||||
g := gift.New(splitFilter...)
|
||||
g.Add(
|
||||
epubimagefilters.CropSplitDoublePage(b),
|
||||
gift.ResizeToFit(e.Image.View.Width, e.Image.View.Height, gift.LanczosResampling),
|
||||
)
|
||||
g.Add(epubimagefilters.CropSplitDoublePage(b))
|
||||
if e.Image.Resize {
|
||||
g.Add(gift.ResizeToFit(e.Image.View.Width, e.Image.View.Height, gift.LanczosResampling))
|
||||
}
|
||||
dst := e.createImage(src, g.Bounds(src.Bounds()))
|
||||
g.Draw(dst, src)
|
||||
images = append(images, dst)
|
||||
|
@ -31,6 +31,7 @@ type Image struct {
|
||||
HasCover bool
|
||||
View *View
|
||||
GrayScale bool
|
||||
Resize bool
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user