mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +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
|
||||
}
|
||||
|
||||
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 {
|
||||
|
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)
|
||||
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user