use ratio 1.5 for perfect both side rendering

This commit is contained in:
Celogeek 2023-04-22 10:24:47 +02:00
parent a2eeda8479
commit 7f195a0b79
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
2 changed files with 17 additions and 2 deletions

View File

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

View File

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