mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-24 07:42:37 +02:00
rename splitted to split
This commit is contained in:
parent
b6db09aa9e
commit
ca73ac9682
@ -118,7 +118,7 @@ func (c *Converter) InitParse() {
|
||||
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.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 split")
|
||||
c.AddBoolParam(&c.Options.KeepDoublePageIfSplit, "keepdoublepageifsplit", c.Options.KeepDoublePageIfSplit, "Keep the double page if split")
|
||||
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.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.")
|
||||
@ -270,7 +270,7 @@ func (c *Converter) Parse() {
|
||||
|
||||
if c.Options.AppleBookCompatibility {
|
||||
c.Options.AutoSplitDoublePage = true
|
||||
c.Options.KeepDoublePageIfSplitted = false
|
||||
c.Options.KeepDoublePageIfSplit = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ type Options struct {
|
||||
AutoContrast bool `yaml:"auto_contrast"`
|
||||
AutoRotate bool `yaml:"auto_rotate"`
|
||||
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
||||
KeepDoublePageIfSplitted bool `yaml:"keep_double_page_if_splitted"`
|
||||
KeepDoublePageIfSplit bool `yaml:"keep_double_page_if_split"`
|
||||
NoBlankImage bool `yaml:"no_blank_image"`
|
||||
Manga bool `yaml:"manga"`
|
||||
HasCover bool `yaml:"has_cover"`
|
||||
@ -81,23 +81,23 @@ type Options struct {
|
||||
// Initialize default options.
|
||||
func New() *Options {
|
||||
return &Options{
|
||||
Profile: "SR",
|
||||
Quality: 85,
|
||||
Grayscale: true,
|
||||
Crop: true,
|
||||
CropRatioLeft: 1,
|
||||
CropRatioUp: 1,
|
||||
CropRatioRight: 1,
|
||||
CropRatioBottom: 3,
|
||||
NoBlankImage: true,
|
||||
HasCover: true,
|
||||
KeepDoublePageIfSplitted: true,
|
||||
SortPathMode: 1,
|
||||
ForegroundColor: "000",
|
||||
BackgroundColor: "FFF",
|
||||
Format: "jpeg",
|
||||
TitlePage: 1,
|
||||
profiles: profiles.New(),
|
||||
Profile: "SR",
|
||||
Quality: 85,
|
||||
Grayscale: true,
|
||||
Crop: true,
|
||||
CropRatioLeft: 1,
|
||||
CropRatioUp: 1,
|
||||
CropRatioRight: 1,
|
||||
CropRatioBottom: 3,
|
||||
NoBlankImage: true,
|
||||
HasCover: true,
|
||||
KeepDoublePageIfSplit: true,
|
||||
SortPathMode: 1,
|
||||
ForegroundColor: "000",
|
||||
BackgroundColor: "FFF",
|
||||
Format: "jpeg",
|
||||
TitlePage: 1,
|
||||
profiles: profiles.New(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ func (o *Options) MarshalJSON() ([]byte, error) {
|
||||
if o.PortraitOnly || !o.AppleBookCompatibility {
|
||||
out["autosplitdoublepage"] = o.AutoSplitDoublePage
|
||||
if o.AutoSplitDoublePage {
|
||||
out["keepdoublepageifsplitted"] = o.KeepDoublePageIfSplitted
|
||||
out["keepdoublepageifsplit"] = o.KeepDoublePageIfSplit
|
||||
}
|
||||
}
|
||||
if o.LimitMb != 0 {
|
||||
@ -244,7 +244,7 @@ func (o *Options) ShowConfig() string {
|
||||
case 1:
|
||||
titlePage = "always"
|
||||
case 2:
|
||||
titlePage = "when epub is splitted"
|
||||
titlePage = "when epub is split"
|
||||
}
|
||||
|
||||
grayscaleMode := "normal"
|
||||
@ -265,28 +265,28 @@ func (o *Options) ShowConfig() string {
|
||||
{"Format", o.Format, true},
|
||||
{"Quality", o.Quality, o.Format == "jpeg"},
|
||||
{"Grayscale", o.Grayscale, true},
|
||||
{"Grayscale Mode", grayscaleMode, o.Grayscale},
|
||||
{"Grayscale mode", grayscaleMode, o.Grayscale},
|
||||
{"Crop", o.Crop, true},
|
||||
{"Crop Ratio", fmt.Sprintf("%d Left - %d Up - %d Right - %d Bottom", o.CropRatioLeft, o.CropRatioUp, o.CropRatioRight, o.CropRatioBottom), o.Crop},
|
||||
{"Crop ratio", fmt.Sprintf("%d Left - %d Up - %d Right - %d Bottom", o.CropRatioLeft, o.CropRatioUp, o.CropRatioRight, o.CropRatioBottom), o.Crop},
|
||||
{"Brightness", o.Brightness, o.Brightness != 0},
|
||||
{"Contrast", o.Contrast, o.Contrast != 0},
|
||||
{"Auto Contrast", o.AutoContrast, true},
|
||||
{"Auto Rotate", o.AutoRotate, true},
|
||||
{"Auto Split DoublePage", o.AutoSplitDoublePage, o.PortraitOnly || !o.AppleBookCompatibility},
|
||||
{"Keep DoublePage If Splitted", o.KeepDoublePageIfSplitted, (o.PortraitOnly || !o.AppleBookCompatibility) && o.AutoSplitDoublePage},
|
||||
{"No Blank Image", o.NoBlankImage, true},
|
||||
{"Auto contrast", o.AutoContrast, true},
|
||||
{"Auto rotate", o.AutoRotate, true},
|
||||
{"Auto split double page", o.AutoSplitDoublePage, o.PortraitOnly || !o.AppleBookCompatibility},
|
||||
{"Keep double page if split", o.KeepDoublePageIfSplit, (o.PortraitOnly || !o.AppleBookCompatibility) && o.AutoSplitDoublePage},
|
||||
{"No blank image", o.NoBlankImage, true},
|
||||
{"Manga", o.Manga, true},
|
||||
{"Has Cover", o.HasCover, true},
|
||||
{"Has cover", o.HasCover, true},
|
||||
{"Limit", fmt.Sprintf("%d Mb", o.LimitMb), o.LimitMb != 0},
|
||||
{"Strip First Directory From Toc", o.StripFirstDirectoryFromToc, true},
|
||||
{"Sort Path Mode", sortpathmode, true},
|
||||
{"Foreground Color", fmt.Sprintf("#%s", o.ForegroundColor), true},
|
||||
{"Background Color", fmt.Sprintf("#%s", o.BackgroundColor), true},
|
||||
{"Strip first directory from toc", o.StripFirstDirectoryFromToc, true},
|
||||
{"Sort path mode", sortpathmode, true},
|
||||
{"Foreground color", fmt.Sprintf("#%s", o.ForegroundColor), true},
|
||||
{"Background color", fmt.Sprintf("#%s", o.BackgroundColor), true},
|
||||
{"Resize", !o.NoResize, true},
|
||||
{"Aspect Ratio", aspectRatio, true},
|
||||
{"Portrait Only", o.PortraitOnly, true},
|
||||
{"Title Page", titlePage, true},
|
||||
{"Apple Book Compatibility", o.AppleBookCompatibility, !o.PortraitOnly},
|
||||
{"Aspect ratio", aspectRatio, true},
|
||||
{"Portrait only", o.PortraitOnly, true},
|
||||
{"Title page", titlePage, true},
|
||||
{"Apple book compatibility", o.AppleBookCompatibility, !o.PortraitOnly},
|
||||
} {
|
||||
if v.Condition {
|
||||
b.WriteString(fmt.Sprintf("\n %-32s: %v", v.Key, v.Value))
|
||||
|
@ -445,7 +445,7 @@ func (e *ePub) Write() error {
|
||||
// Double Page or Last Image that is not a double page
|
||||
if !e.Image.View.PortraitOnly &&
|
||||
(img.DoublePage ||
|
||||
(!e.Image.KeepDoublePageIfSplitted && img.Part == 1) ||
|
||||
(!e.Image.KeepDoublePageIfSplit && img.Part == 1) ||
|
||||
(img.Part == 0 && img == lastImage)) {
|
||||
if err := e.writeBlank(wz, img); err != nil {
|
||||
return err
|
||||
|
@ -82,7 +82,7 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
|
||||
|
||||
// do not keep double page if requested
|
||||
if !(img.DoublePage && input.Id > 0 &&
|
||||
e.Options.Image.AutoSplitDoublePage && !e.Options.Image.KeepDoublePageIfSplitted) {
|
||||
e.Options.Image.AutoSplitDoublePage && !e.Options.Image.KeepDoublePageIfSplit) {
|
||||
if err = imgStorage.Add(img.EPUBImgPath(), img.Raw, e.Image.Quality); err != nil {
|
||||
bar.Close()
|
||||
fmt.Fprintf(os.Stderr, "error with %s: %s", input.Name, err)
|
||||
|
@ -22,23 +22,23 @@ type View struct {
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
Crop *Crop
|
||||
Quality int
|
||||
Brightness int
|
||||
Contrast int
|
||||
AutoContrast bool
|
||||
AutoRotate bool
|
||||
AutoSplitDoublePage bool
|
||||
KeepDoublePageIfSplitted bool
|
||||
NoBlankImage bool
|
||||
Manga bool
|
||||
HasCover bool
|
||||
View *View
|
||||
GrayScale bool
|
||||
GrayScaleMode int
|
||||
Resize bool
|
||||
Format string
|
||||
AppleBookCompatibility bool
|
||||
Crop *Crop
|
||||
Quality int
|
||||
Brightness int
|
||||
Contrast int
|
||||
AutoContrast bool
|
||||
AutoRotate bool
|
||||
AutoSplitDoublePage bool
|
||||
KeepDoublePageIfSplit bool
|
||||
NoBlankImage bool
|
||||
Manga bool
|
||||
HasCover bool
|
||||
View *View
|
||||
GrayScale bool
|
||||
GrayScaleMode int
|
||||
Resize bool
|
||||
Format string
|
||||
AppleBookCompatibility bool
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
|
@ -180,7 +180,7 @@ func getManifest(o *ContentOptions) []tag {
|
||||
img,
|
||||
!o.ImageOptions.View.PortraitOnly &&
|
||||
(img.DoublePage ||
|
||||
(!o.ImageOptions.KeepDoublePageIfSplitted && img.Part == 1) ||
|
||||
(!o.ImageOptions.KeepDoublePageIfSplit && img.Part == 1) ||
|
||||
(img.Part == 0 && img == lastImage)))
|
||||
}
|
||||
|
||||
|
34
main.go
34
main.go
@ -122,23 +122,23 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
||||
Quiet: cmd.Options.Quiet,
|
||||
Json: cmd.Options.Json,
|
||||
Image: &epuboptions.Image{
|
||||
Crop: &epuboptions.Crop{Enabled: cmd.Options.Crop, Left: cmd.Options.CropRatioLeft, Up: cmd.Options.CropRatioUp, Right: cmd.Options.CropRatioRight, Bottom: cmd.Options.CropRatioBottom},
|
||||
Quality: cmd.Options.Quality,
|
||||
Brightness: cmd.Options.Brightness,
|
||||
Contrast: cmd.Options.Contrast,
|
||||
AutoContrast: cmd.Options.AutoContrast,
|
||||
AutoRotate: cmd.Options.AutoRotate,
|
||||
AutoSplitDoublePage: cmd.Options.AutoSplitDoublePage,
|
||||
KeepDoublePageIfSplitted: cmd.Options.KeepDoublePageIfSplitted,
|
||||
NoBlankImage: cmd.Options.NoBlankImage,
|
||||
Manga: cmd.Options.Manga,
|
||||
HasCover: cmd.Options.HasCover,
|
||||
View: &epuboptions.View{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}},
|
||||
GrayScale: cmd.Options.Grayscale,
|
||||
GrayScaleMode: cmd.Options.GrayscaleMode,
|
||||
Resize: !cmd.Options.NoResize,
|
||||
Format: cmd.Options.Format,
|
||||
AppleBookCompatibility: cmd.Options.AppleBookCompatibility,
|
||||
Crop: &epuboptions.Crop{Enabled: cmd.Options.Crop, Left: cmd.Options.CropRatioLeft, Up: cmd.Options.CropRatioUp, Right: cmd.Options.CropRatioRight, Bottom: cmd.Options.CropRatioBottom},
|
||||
Quality: cmd.Options.Quality,
|
||||
Brightness: cmd.Options.Brightness,
|
||||
Contrast: cmd.Options.Contrast,
|
||||
AutoContrast: cmd.Options.AutoContrast,
|
||||
AutoRotate: cmd.Options.AutoRotate,
|
||||
AutoSplitDoublePage: cmd.Options.AutoSplitDoublePage,
|
||||
KeepDoublePageIfSplit: cmd.Options.KeepDoublePageIfSplit,
|
||||
NoBlankImage: cmd.Options.NoBlankImage,
|
||||
Manga: cmd.Options.Manga,
|
||||
HasCover: cmd.Options.HasCover,
|
||||
View: &epuboptions.View{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}},
|
||||
GrayScale: cmd.Options.Grayscale,
|
||||
GrayScaleMode: cmd.Options.GrayscaleMode,
|
||||
Resize: !cmd.Options.NoResize,
|
||||
Format: cmd.Options.Format,
|
||||
AppleBookCompatibility: cmd.Options.AppleBookCompatibility,
|
||||
},
|
||||
}).Write(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user