mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-24 15:52:38 +02:00
display perfect dim
This commit is contained in:
parent
d96e63bc50
commit
51c04fecb0
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user