mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
add option keepdoublepageifsplitted
This commit is contained in:
parent
7ea9b9f86e
commit
21cbde14bc
@ -119,6 +119,7 @@ func (c *Converter) InitParse() {
|
|||||||
c.AddBoolParam(&c.Options.AutoContrast, "autocontrast", c.Options.AutoContrast, "Improve contrast automatically")
|
c.AddBoolParam(&c.Options.AutoContrast, "autocontrast", c.Options.AutoContrast, "Improve contrast automatically")
|
||||||
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.KeepDoublePageIfSplitted, "keepdoublepageifsplitted", c.Options.KeepDoublePageIfSplitted, "Keep the double page if splitted")
|
||||||
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.")
|
||||||
|
@ -35,6 +35,7 @@ type Options struct {
|
|||||||
AutoContrast bool `yaml:"auto_contrast"`
|
AutoContrast bool `yaml:"auto_contrast"`
|
||||||
AutoRotate bool `yaml:"auto_rotate"`
|
AutoRotate bool `yaml:"auto_rotate"`
|
||||||
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
||||||
|
KeepDoublePageIfSplitted bool `yaml:"keep_double_page_if_splitted"`
|
||||||
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"`
|
||||||
@ -87,6 +88,7 @@ func New() *Options {
|
|||||||
CropRatioBottom: 3,
|
CropRatioBottom: 3,
|
||||||
NoBlankImage: true,
|
NoBlankImage: true,
|
||||||
HasCover: true,
|
HasCover: true,
|
||||||
|
KeepDoublePageIfSplitted: true,
|
||||||
SortPathMode: 1,
|
SortPathMode: 1,
|
||||||
ForegroundColor: "000",
|
ForegroundColor: "000",
|
||||||
BackgroundColor: "FFF",
|
BackgroundColor: "FFF",
|
||||||
@ -208,6 +210,7 @@ func (o *Options) ShowConfig() string {
|
|||||||
{"AutoContrast", o.AutoContrast, true},
|
{"AutoContrast", o.AutoContrast, true},
|
||||||
{"AutoRotate", o.AutoRotate, true},
|
{"AutoRotate", o.AutoRotate, true},
|
||||||
{"AutoSplitDoublePage", o.AutoSplitDoublePage, true},
|
{"AutoSplitDoublePage", o.AutoSplitDoublePage, true},
|
||||||
|
{"KeepDoublePageIfSplitted", o.KeepDoublePageIfSplitted, o.AutoSplitDoublePage},
|
||||||
{"NoBlankImage", o.NoBlankImage, true},
|
{"NoBlankImage", o.NoBlankImage, true},
|
||||||
{"Manga", o.Manga, true},
|
{"Manga", o.Manga, true},
|
||||||
{"HasCover", o.HasCover, true},
|
{"HasCover", o.HasCover, true},
|
||||||
|
@ -442,7 +442,10 @@ func (e *ePub) Write() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Double Page or Last Image that is not a double page
|
// Double Page or Last Image that is not a double page
|
||||||
if !e.Image.View.PortraitOnly && (img.DoublePage || (img.Part == 0 && img == lastImage)) {
|
if !e.Image.View.PortraitOnly &&
|
||||||
|
(img.DoublePage ||
|
||||||
|
(!e.Image.KeepDoublePageIfSplitted && img.Part == 1) ||
|
||||||
|
(img.Part == 0 && img == lastImage)) {
|
||||||
if err := e.writeBlank(wz, img); err != nil {
|
if err := e.writeBlank(wz, img); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,14 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
|
|||||||
Error: input.Error,
|
Error: input.Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not keep double page if requested
|
||||||
|
if !img.IsCover &&
|
||||||
|
img.DoublePage &&
|
||||||
|
e.Options.Image.AutoSplitDoublePage &&
|
||||||
|
!e.Options.Image.KeepDoublePageIfSplitted {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if err = imgStorage.Add(img.EPUBImgPath(), dst, e.Image.Quality); err != nil {
|
if err = imgStorage.Add(img.EPUBImgPath(), dst, e.Image.Quality); err != nil {
|
||||||
bar.Close()
|
bar.Close()
|
||||||
fmt.Fprintf(os.Stderr, "error with %s: %s", input.Name, err)
|
fmt.Fprintf(os.Stderr, "error with %s: %s", input.Name, err)
|
||||||
|
@ -29,6 +29,7 @@ type Image struct {
|
|||||||
AutoContrast bool
|
AutoContrast bool
|
||||||
AutoRotate bool
|
AutoRotate bool
|
||||||
AutoSplitDoublePage bool
|
AutoSplitDoublePage bool
|
||||||
|
KeepDoublePageIfSplitted bool
|
||||||
NoBlankImage bool
|
NoBlankImage bool
|
||||||
Manga bool
|
Manga bool
|
||||||
HasCover bool
|
HasCover bool
|
||||||
|
@ -174,7 +174,12 @@ func getManifest(o *ContentOptions) []tag {
|
|||||||
|
|
||||||
lastImage := o.Images[len(o.Images)-1]
|
lastImage := o.Images[len(o.Images)-1]
|
||||||
for _, img := range o.Images {
|
for _, img := range o.Images {
|
||||||
addTag(img, !o.ImageOptions.View.PortraitOnly && (img.DoublePage || (img.Part == 0 && img == lastImage)))
|
addTag(
|
||||||
|
img,
|
||||||
|
!o.ImageOptions.View.PortraitOnly &&
|
||||||
|
(img.DoublePage ||
|
||||||
|
(!o.ImageOptions.KeepDoublePageIfSplitted && img.Part == 1) ||
|
||||||
|
(img.Part == 0 && img == lastImage)))
|
||||||
}
|
}
|
||||||
|
|
||||||
items = append(items, imageTags...)
|
items = append(items, imageTags...)
|
||||||
@ -212,7 +217,7 @@ func getSpineAuto(o *ContentOptions) []tag {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
for _, img := range o.Images {
|
for _, img := range o.Images {
|
||||||
if img.DoublePage && o.ImageOptions.Manga == isOnTheRight {
|
if (img.DoublePage || img.Part == 1) && o.ImageOptions.Manga == isOnTheRight {
|
||||||
spine = append(spine, tag{
|
spine = append(spine, tag{
|
||||||
"itemref",
|
"itemref",
|
||||||
tagAttrs{"idref": img.SpaceKey(), "properties": getSpreadBlank()},
|
tagAttrs{"idref": img.SpaceKey(), "properties": getSpreadBlank()},
|
||||||
|
1
main.go
1
main.go
@ -121,6 +121,7 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
AutoContrast: cmd.Options.AutoContrast,
|
AutoContrast: cmd.Options.AutoContrast,
|
||||||
AutoRotate: cmd.Options.AutoRotate,
|
AutoRotate: cmd.Options.AutoRotate,
|
||||||
AutoSplitDoublePage: cmd.Options.AutoSplitDoublePage,
|
AutoSplitDoublePage: cmd.Options.AutoSplitDoublePage,
|
||||||
|
KeepDoublePageIfSplitted: cmd.Options.KeepDoublePageIfSplitted,
|
||||||
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