mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
add option to not preserve aspect on split double page
This commit is contained in:
parent
62fc520ebb
commit
87faac877c
@ -122,6 +122,7 @@ func (c *Converter) InitParse() {
|
|||||||
c.AddBoolParam(&c.Options.AutoRotate, "autorotate", c.Options.AutoRotate, "Auto Rotate page when width > height")
|
c.AddBoolParam(&c.Options.AutoRotate, "autorotate", c.Options.AutoRotate, "Auto Rotate page when width > height")
|
||||||
c.AddBoolParam(&c.Options.AutoSplitDoublePage, "autosplitdoublepage", c.Options.AutoSplitDoublePage, "Auto Split double page when width > height")
|
c.AddBoolParam(&c.Options.AutoSplitDoublePage, "autosplitdoublepage", c.Options.AutoSplitDoublePage, "Auto Split double page when width > height")
|
||||||
c.AddBoolParam(&c.Options.KeepDoublePageIfSplit, "keepdoublepageifsplit", c.Options.KeepDoublePageIfSplit, "Keep the double page if split")
|
c.AddBoolParam(&c.Options.KeepDoublePageIfSplit, "keepdoublepageifsplit", c.Options.KeepDoublePageIfSplit, "Keep the double page if split")
|
||||||
|
c.AddBoolParam(&c.Options.KeepSplitDoublePageAspect, "keepsplitdoublepageaspect", c.Options.KeepSplitDoublePageAspect, "Keep aspect of split part of a double page (best for landscape rendering)")
|
||||||
c.AddBoolParam(&c.Options.NoBlankImage, "noblankimage", c.Options.NoBlankImage, "Remove blank image")
|
c.AddBoolParam(&c.Options.NoBlankImage, "noblankimage", c.Options.NoBlankImage, "Remove blank image")
|
||||||
c.AddBoolParam(&c.Options.Manga, "manga", c.Options.Manga, "Manga mode (right to left)")
|
c.AddBoolParam(&c.Options.Manga, "manga", c.Options.Manga, "Manga mode (right to left)")
|
||||||
c.AddBoolParam(&c.Options.HasCover, "hascover", c.Options.HasCover, "Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.")
|
c.AddBoolParam(&c.Options.HasCover, "hascover", c.Options.HasCover, "Has cover. Indicate if your comic have a cover. The first page will be used as a cover and include after the title.")
|
||||||
@ -274,6 +275,11 @@ func (c *Converter) Parse() {
|
|||||||
if c.Options.AppleBookCompatibility {
|
if c.Options.AppleBookCompatibility {
|
||||||
c.Options.AutoSplitDoublePage = true
|
c.Options.AutoSplitDoublePage = true
|
||||||
c.Options.KeepDoublePageIfSplit = false
|
c.Options.KeepDoublePageIfSplit = false
|
||||||
|
c.Options.KeepSplitDoublePageAspect = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Options.PortraitOnly {
|
||||||
|
c.Options.KeepSplitDoublePageAspect = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ type Options struct {
|
|||||||
AutoRotate bool `yaml:"auto_rotate"`
|
AutoRotate bool `yaml:"auto_rotate"`
|
||||||
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
||||||
KeepDoublePageIfSplit bool `yaml:"keep_double_page_if_split"`
|
KeepDoublePageIfSplit bool `yaml:"keep_double_page_if_split"`
|
||||||
|
KeepSplitDoublePageAspect bool `yaml:"keep_split_double_page_aspect"`
|
||||||
NoBlankImage bool `yaml:"no_blank_image"`
|
NoBlankImage bool `yaml:"no_blank_image"`
|
||||||
Manga bool `yaml:"manga"`
|
Manga bool `yaml:"manga"`
|
||||||
HasCover bool `yaml:"has_cover"`
|
HasCover bool `yaml:"has_cover"`
|
||||||
@ -90,11 +91,10 @@ func New() *Options {
|
|||||||
CropRatioUp: 1,
|
CropRatioUp: 1,
|
||||||
CropRatioRight: 1,
|
CropRatioRight: 1,
|
||||||
CropRatioBottom: 3,
|
CropRatioBottom: 3,
|
||||||
CropLimit: 10,
|
|
||||||
CropSkipIfLimitReached: true,
|
|
||||||
NoBlankImage: true,
|
NoBlankImage: true,
|
||||||
HasCover: true,
|
HasCover: true,
|
||||||
KeepDoublePageIfSplit: true,
|
KeepDoublePageIfSplit: true,
|
||||||
|
KeepSplitDoublePageAspect: true,
|
||||||
SortPathMode: 1,
|
SortPathMode: 1,
|
||||||
ForegroundColor: "000",
|
ForegroundColor: "000",
|
||||||
BackgroundColor: "FFF",
|
BackgroundColor: "FFF",
|
||||||
@ -179,6 +179,7 @@ func (o *Options) MarshalJSON() ([]byte, error) {
|
|||||||
out["autosplitdoublepage"] = o.AutoSplitDoublePage
|
out["autosplitdoublepage"] = o.AutoSplitDoublePage
|
||||||
if o.AutoSplitDoublePage {
|
if o.AutoSplitDoublePage {
|
||||||
out["keepdoublepageifsplit"] = o.KeepDoublePageIfSplit
|
out["keepdoublepageifsplit"] = o.KeepDoublePageIfSplit
|
||||||
|
out["keepsplitdoublepageaspect"] = o.KeepSplitDoublePageAspect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if o.LimitMb != 0 {
|
if o.LimitMb != 0 {
|
||||||
@ -285,6 +286,7 @@ func (o *Options) ShowConfig() string {
|
|||||||
{"Auto rotate", o.AutoRotate, true},
|
{"Auto rotate", o.AutoRotate, true},
|
||||||
{"Auto split double page", o.AutoSplitDoublePage, o.PortraitOnly || !o.AppleBookCompatibility},
|
{"Auto split double page", o.AutoSplitDoublePage, o.PortraitOnly || !o.AppleBookCompatibility},
|
||||||
{"Keep double page if split", o.KeepDoublePageIfSplit, (o.PortraitOnly || !o.AppleBookCompatibility) && o.AutoSplitDoublePage},
|
{"Keep double page if split", o.KeepDoublePageIfSplit, (o.PortraitOnly || !o.AppleBookCompatibility) && o.AutoSplitDoublePage},
|
||||||
|
{"Keep split double page aspect", o.KeepSplitDoublePageAspect, (o.PortraitOnly || !o.AppleBookCompatibility) && o.AutoSplitDoublePage},
|
||||||
{"No blank image", o.NoBlankImage, true},
|
{"No blank image", o.NoBlankImage, true},
|
||||||
{"Manga", o.Manga, true},
|
{"Manga", o.Manga, true},
|
||||||
{"Has cover", o.HasCover, true},
|
{"Has cover", o.HasCover, true},
|
||||||
|
@ -180,7 +180,7 @@ func (e *EPUBImageProcessor) transformImage(input *task, part int, right bool) *
|
|||||||
|
|
||||||
// In portrait only, we don't need to keep aspect ratio between each split.
|
// In portrait only, we don't need to keep aspect ratio between each split.
|
||||||
// We first cut, the crop.
|
// We first cut, the crop.
|
||||||
if part > 0 && e.Image.View.PortraitOnly {
|
if part > 0 && !e.Image.KeepSplitDoublePageAspect {
|
||||||
g.Add(epubimagefilters.CropSplitDoublePage(right))
|
g.Add(epubimagefilters.CropSplitDoublePage(right))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ func (e *EPUBImageProcessor) transformImage(input *task, part int, right bool) *
|
|||||||
|
|
||||||
// With landscape support, we need to keep aspect ratio between each split
|
// With landscape support, we need to keep aspect ratio between each split
|
||||||
// We first crop, then cut
|
// We first crop, then cut
|
||||||
if part > 0 && !e.Image.View.PortraitOnly {
|
if part > 0 && e.Image.KeepSplitDoublePageAspect {
|
||||||
g.Add(epubimagefilters.CropSplitDoublePage(right))
|
g.Add(epubimagefilters.CropSplitDoublePage(right))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ type Image struct {
|
|||||||
AutoRotate bool
|
AutoRotate bool
|
||||||
AutoSplitDoublePage bool
|
AutoSplitDoublePage bool
|
||||||
KeepDoublePageIfSplit bool
|
KeepDoublePageIfSplit bool
|
||||||
|
KeepSplitDoublePageAspect bool
|
||||||
NoBlankImage bool
|
NoBlankImage bool
|
||||||
Manga bool
|
Manga bool
|
||||||
HasCover bool
|
HasCover bool
|
||||||
|
1
main.go
1
main.go
@ -141,6 +141,7 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
AutoRotate: cmd.Options.AutoRotate,
|
AutoRotate: cmd.Options.AutoRotate,
|
||||||
AutoSplitDoublePage: cmd.Options.AutoSplitDoublePage,
|
AutoSplitDoublePage: cmd.Options.AutoSplitDoublePage,
|
||||||
KeepDoublePageIfSplit: cmd.Options.KeepDoublePageIfSplit,
|
KeepDoublePageIfSplit: cmd.Options.KeepDoublePageIfSplit,
|
||||||
|
KeepSplitDoublePageAspect: cmd.Options.KeepSplitDoublePageAspect,
|
||||||
NoBlankImage: cmd.Options.NoBlankImage,
|
NoBlankImage: cmd.Options.NoBlankImage,
|
||||||
Manga: cmd.Options.Manga,
|
Manga: cmd.Options.Manga,
|
||||||
HasCover: cmd.Options.HasCover,
|
HasCover: cmd.Options.HasCover,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user