mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
use ratio 1.5 for perfect both side rendering
This commit is contained in:
parent
a2eeda8479
commit
7f195a0b79
@ -12,6 +12,19 @@ type Profile struct {
|
|||||||
Height int
|
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
|
type Profiles []Profile
|
||||||
|
|
||||||
func New() Profiles {
|
func New() Profiles {
|
||||||
|
6
main.go
6
main.go
@ -91,6 +91,8 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
fmt.Fprintln(os.Stderr, cmd.Options)
|
fmt.Fprintln(os.Stderr, cmd.Options)
|
||||||
|
|
||||||
profile := cmd.Options.GetProfile()
|
profile := cmd.Options.GetProfile()
|
||||||
|
perfectWidth, perfectHeight := profile.PerfectDim()
|
||||||
|
|
||||||
if err := epub.NewEpub(&epub.EpubOptions{
|
if err := epub.NewEpub(&epub.EpubOptions{
|
||||||
Input: cmd.Options.Input,
|
Input: cmd.Options.Input,
|
||||||
Output: cmd.Options.Output,
|
Output: cmd.Options.Output,
|
||||||
@ -102,8 +104,8 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
DryVerbose: cmd.Options.DryVerbose,
|
DryVerbose: cmd.Options.DryVerbose,
|
||||||
SortPathMode: cmd.Options.SortPathMode,
|
SortPathMode: cmd.Options.SortPathMode,
|
||||||
ImageOptions: &epub.ImageOptions{
|
ImageOptions: &epub.ImageOptions{
|
||||||
ViewWidth: profile.Width,
|
ViewWidth: perfectWidth,
|
||||||
ViewHeight: profile.Height,
|
ViewHeight: perfectHeight,
|
||||||
Quality: cmd.Options.Quality,
|
Quality: cmd.Options.Quality,
|
||||||
Crop: cmd.Options.Crop,
|
Crop: cmd.Options.Crop,
|
||||||
Brightness: cmd.Options.Brightness,
|
Brightness: cmd.Options.Brightness,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user