diff --git a/internal/converter/profiles/core.go b/internal/converter/profiles/core.go index 0a5a2fd..e370196 100644 --- a/internal/converter/profiles/core.go +++ b/internal/converter/profiles/core.go @@ -12,6 +12,19 @@ type Profile struct { Height int } +const perfectRatio = 1.5 + +func (p Profile) PerfectDim() (int, int) { + width, height := float64(p.Width), float64(p.Height) + perfectWidth, perfectHeight := height/perfectRatio, width*perfectRatio + if perfectWidth > width { + perfectWidth = width + } else { + perfectHeight = height + } + return int(perfectWidth), int(perfectHeight) +} + type Profiles []Profile func New() Profiles { diff --git a/main.go b/main.go index 116227b..e2cb6b0 100644 --- a/main.go +++ b/main.go @@ -91,6 +91,8 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s fmt.Fprintln(os.Stderr, cmd.Options) profile := cmd.Options.GetProfile() + perfectWidth, perfectHeight := profile.PerfectDim() + if err := epub.NewEpub(&epub.EpubOptions{ Input: cmd.Options.Input, Output: cmd.Options.Output, @@ -102,8 +104,8 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s DryVerbose: cmd.Options.DryVerbose, SortPathMode: cmd.Options.SortPathMode, ImageOptions: &epub.ImageOptions{ - ViewWidth: profile.Width, - ViewHeight: profile.Height, + ViewWidth: perfectWidth, + ViewHeight: perfectHeight, Quality: cmd.Options.Quality, Crop: cmd.Options.Crop, Brightness: cmd.Options.Brightness,