mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
display perfect dim
This commit is contained in:
parent
d96e63bc50
commit
51c04fecb0
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/celogeek/go-comic-converter/v2/internal/converter/profiles"
|
"github.com/celogeek/go-comic-converter/v2/internal/converter/profiles"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -111,7 +112,7 @@ func (o *Options) LoadDefault() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Options) ShowDefault() string {
|
func (o *Options) ShowDefault() string {
|
||||||
var profileDesc string
|
var profileDesc, viewDesc string
|
||||||
profile := o.GetProfile()
|
profile := o.GetProfile()
|
||||||
if profile != nil {
|
if profile != nil {
|
||||||
profileDesc = fmt.Sprintf(
|
profileDesc = fmt.Sprintf(
|
||||||
@ -121,6 +122,13 @@ func (o *Options) ShowDefault() string {
|
|||||||
profile.Width,
|
profile.Width,
|
||||||
profile.Height,
|
profile.Height,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
perfectWidth, perfectHeight := profile.PerfectDim()
|
||||||
|
viewDesc = fmt.Sprintf(
|
||||||
|
"%dx%d",
|
||||||
|
perfectWidth,
|
||||||
|
perfectHeight,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
limitmb := "nolimit"
|
limitmb := "nolimit"
|
||||||
if o.LimitMb > 0 {
|
if o.LimitMb > 0 {
|
||||||
@ -139,6 +147,8 @@ func (o *Options) ShowDefault() string {
|
|||||||
|
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
Profile : %s
|
Profile : %s
|
||||||
|
ViewRatio : 1:%s
|
||||||
|
View : %s
|
||||||
Quality : %d
|
Quality : %d
|
||||||
Crop : %v
|
Crop : %v
|
||||||
Brightness : %d
|
Brightness : %d
|
||||||
@ -152,6 +162,8 @@ func (o *Options) ShowDefault() string {
|
|||||||
StripFirstDirectoryFromToc: %v
|
StripFirstDirectoryFromToc: %v
|
||||||
SortPathMode : %s`,
|
SortPathMode : %s`,
|
||||||
profileDesc,
|
profileDesc,
|
||||||
|
strings.TrimRight(fmt.Sprintf("%f", profiles.PerfectRatio), "0"),
|
||||||
|
viewDesc,
|
||||||
o.Quality,
|
o.Quality,
|
||||||
o.Crop,
|
o.Crop,
|
||||||
o.Brightness,
|
o.Brightness,
|
||||||
|
@ -12,11 +12,11 @@ type Profile struct {
|
|||||||
Height int
|
Height int
|
||||||
}
|
}
|
||||||
|
|
||||||
const perfectRatio = 1.5
|
const PerfectRatio = 1.5
|
||||||
|
|
||||||
func (p Profile) PerfectDim() (int, int) {
|
func (p Profile) PerfectDim() (int, int) {
|
||||||
width, height := float64(p.Width), float64(p.Height)
|
width, height := float64(p.Width), float64(p.Height)
|
||||||
perfectWidth, perfectHeight := height/perfectRatio, width*perfectRatio
|
perfectWidth, perfectHeight := height/PerfectRatio, width*PerfectRatio
|
||||||
if perfectWidth > width {
|
if perfectWidth > width {
|
||||||
perfectWidth = width
|
perfectWidth = width
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user