display perfect dim

This commit is contained in:
Celogeek 2023-04-22 10:53:15 +02:00
parent d96e63bc50
commit 51c04fecb0
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
2 changed files with 15 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/celogeek/go-comic-converter/v2/internal/converter/profiles"
"gopkg.in/yaml.v3"
@ -111,7 +112,7 @@ func (o *Options) LoadDefault() error {
}
func (o *Options) ShowDefault() string {
var profileDesc string
var profileDesc, viewDesc string
profile := o.GetProfile()
if profile != nil {
profileDesc = fmt.Sprintf(
@ -121,6 +122,13 @@ func (o *Options) ShowDefault() string {
profile.Width,
profile.Height,
)
perfectWidth, perfectHeight := profile.PerfectDim()
viewDesc = fmt.Sprintf(
"%dx%d",
perfectWidth,
perfectHeight,
)
}
limitmb := "nolimit"
if o.LimitMb > 0 {
@ -139,6 +147,8 @@ func (o *Options) ShowDefault() string {
return fmt.Sprintf(`
Profile : %s
ViewRatio : 1:%s
View : %s
Quality : %d
Crop : %v
Brightness : %d
@ -152,6 +162,8 @@ func (o *Options) ShowDefault() string {
StripFirstDirectoryFromToc: %v
SortPathMode : %s`,
profileDesc,
strings.TrimRight(fmt.Sprintf("%f", profiles.PerfectRatio), "0"),
viewDesc,
o.Quality,
o.Crop,
o.Brightness,

View File

@ -12,11 +12,11 @@ type Profile struct {
Height int
}
const perfectRatio = 1.5
const PerfectRatio = 1.5
func (p Profile) PerfectDim() (int, int) {
width, height := float64(p.Width), float64(p.Height)
perfectWidth, perfectHeight := height/perfectRatio, width*perfectRatio
perfectWidth, perfectHeight := height/PerfectRatio, width*PerfectRatio
if perfectWidth > width {
perfectWidth = width
} else {