option to keep skip resize filter

This commit is contained in:
Celogeek 2023-05-01 17:09:47 +02:00
parent 13103b0eba
commit ee00ed2615
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
5 changed files with 16 additions and 8 deletions

View File

@ -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")

View File

@ -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))
}

View File

@ -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)

View File

@ -31,6 +31,7 @@ type Image struct {
HasCover bool
View *View
GrayScale bool
Resize bool
}
type Options struct {

View File

@ -138,6 +138,7 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
Background: cmd.Options.BackgroundColor,
},
},
Resize: !cmd.Options.NoResize,
},
}).Write(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)