diff --git a/internal/converter/converter.go b/internal/converter/converter.go index 8d1e026..0a4dee2 100644 --- a/internal/converter/converter.go +++ b/internal/converter/converter.go @@ -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") diff --git a/internal/converter/options/converter_options.go b/internal/converter/options/converter_options.go index 7461f5c..fa8b776 100644 --- a/internal/converter/options/converter_options.go +++ b/internal/converter/options/converter_options.go @@ -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)) } diff --git a/internal/epub/imageprocessor/epub_image_processor.go b/internal/epub/imageprocessor/epub_image_processor.go index 948c757..ff1cafa 100644 --- a/internal/epub/imageprocessor/epub_image_processor.go +++ b/internal/epub/imageprocessor/epub_image_processor.go @@ -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) diff --git a/internal/epub/options/epub_options.go b/internal/epub/options/epub_options.go index 9fb62cd..9432b98 100644 --- a/internal/epub/options/epub_options.go +++ b/internal/epub/options/epub_options.go @@ -31,6 +31,7 @@ type Image struct { HasCover bool View *View GrayScale bool + Resize bool } type Options struct { diff --git a/main.go b/main.go index d418a34..2f4c0a6 100644 --- a/main.go +++ b/main.go @@ -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)