mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
add option to portrait only mode
This commit is contained in:
parent
d7e311488f
commit
bd8506d367
@ -128,6 +128,7 @@ func (c *Converter) InitParse() {
|
||||
c.AddBoolParam(&c.Options.NoResize, "noresize", c.Options.NoResize, "Do not reduce image size if exceed device size")
|
||||
c.AddStringParam(&c.Options.Format, "format", c.Options.Format, "Format of output images: jpeg (lossy), png (lossless)")
|
||||
c.AddFloatParam(&c.Options.AspectRatio, "aspect-ratio", c.Options.AspectRatio, "Aspect ratio (height/width) of the output\n -1 = same as device\n 0 = same as source\n1.6 = amazon advice for kindle")
|
||||
c.AddBoolParam(&c.Options.PortraitOnly, "portrait-only", c.Options.PortraitOnly, "Portrait only: force orientation to portrait only.")
|
||||
|
||||
c.AddSection("Default config")
|
||||
c.AddBoolParam(&c.Options.Show, "show", false, "Show your default parameters")
|
||||
|
@ -44,6 +44,7 @@ type Options struct {
|
||||
NoResize bool `yaml:"noresize"`
|
||||
Format string `yaml:"format"`
|
||||
AspectRatio float64 `yaml:"aspect_ratio"`
|
||||
PortraitOnly bool `yaml:"portrait_only"`
|
||||
|
||||
// Default Config
|
||||
Show bool `yaml:"-"`
|
||||
@ -73,30 +74,20 @@ type Options struct {
|
||||
// Initialize default options.
|
||||
func New() *Options {
|
||||
return &Options{
|
||||
Profile: "",
|
||||
Quality: 85,
|
||||
Grayscale: true,
|
||||
Crop: true,
|
||||
CropRatioLeft: 1,
|
||||
CropRatioUp: 1,
|
||||
CropRatioRight: 1,
|
||||
CropRatioBottom: 3,
|
||||
Brightness: 0,
|
||||
Contrast: 0,
|
||||
AutoRotate: false,
|
||||
AutoSplitDoublePage: false,
|
||||
NoBlankImage: true,
|
||||
Manga: false,
|
||||
HasCover: true,
|
||||
LimitMb: 0,
|
||||
StripFirstDirectoryFromToc: false,
|
||||
SortPathMode: 1,
|
||||
ForegroundColor: "000",
|
||||
BackgroundColor: "FFF",
|
||||
NoResize: false,
|
||||
Format: "jpeg",
|
||||
AspectRatio: 0,
|
||||
profiles: profiles.New(),
|
||||
Quality: 85,
|
||||
Grayscale: true,
|
||||
Crop: true,
|
||||
CropRatioLeft: 1,
|
||||
CropRatioUp: 1,
|
||||
CropRatioRight: 1,
|
||||
CropRatioBottom: 3,
|
||||
NoBlankImage: true,
|
||||
HasCover: true,
|
||||
SortPathMode: 1,
|
||||
ForegroundColor: "000",
|
||||
BackgroundColor: "FFF",
|
||||
Format: "jpeg",
|
||||
profiles: profiles.New(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,6 +193,7 @@ func (o *Options) ShowConfig() string {
|
||||
{"Background Color", fmt.Sprintf("#%s", o.BackgroundColor), true},
|
||||
{"Resize", !o.NoResize, true},
|
||||
{"Aspect Ratio", aspectRatio, true},
|
||||
{"Portrait Only", o.PortraitOnly, true},
|
||||
} {
|
||||
if v.Condition {
|
||||
b.WriteString(fmt.Sprintf("\n %-26s: %v", v.Key, v.Value))
|
||||
|
@ -17,6 +17,7 @@ type Color struct {
|
||||
type View struct {
|
||||
Width, Height int
|
||||
AspectRatio float64
|
||||
PortraitOnly bool
|
||||
Color Color
|
||||
}
|
||||
|
||||
|
7
main.go
7
main.go
@ -130,9 +130,10 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
||||
Manga: cmd.Options.Manga,
|
||||
HasCover: cmd.Options.HasCover,
|
||||
View: &epuboptions.View{
|
||||
Width: profile.Width,
|
||||
Height: profile.Height,
|
||||
AspectRatio: cmd.Options.AspectRatio,
|
||||
Width: profile.Width,
|
||||
Height: profile.Height,
|
||||
AspectRatio: cmd.Options.AspectRatio,
|
||||
PortraitOnly: cmd.Options.PortraitOnly,
|
||||
Color: epuboptions.Color{
|
||||
Foreground: cmd.Options.ForegroundColor,
|
||||
Background: cmd.Options.BackgroundColor,
|
||||
|
Loading…
x
Reference in New Issue
Block a user