rename splitted to split

This commit is contained in:
Celogeek 2024-02-08 20:49:35 +02:00
parent b6db09aa9e
commit ca73ac9682
Signed by: celogeek
SSH Key Fingerprint: SHA256:DEDfxIK2nUWXbslbRkww3zsauDjhWHlTXar+ak4lDJ4
7 changed files with 75 additions and 75 deletions

View File

@ -118,7 +118,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 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.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.")
@ -270,7 +270,7 @@ func (c *Converter) Parse() {
if c.Options.AppleBookCompatibility { if c.Options.AppleBookCompatibility {
c.Options.AutoSplitDoublePage = true c.Options.AutoSplitDoublePage = true
c.Options.KeepDoublePageIfSplitted = false c.Options.KeepDoublePageIfSplit = false
} }
} }

View File

@ -36,7 +36,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"` KeepDoublePageIfSplit bool `yaml:"keep_double_page_if_split"`
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"`
@ -81,23 +81,23 @@ type Options struct {
// Initialize default options. // Initialize default options.
func New() *Options { func New() *Options {
return &Options{ return &Options{
Profile: "SR", Profile: "SR",
Quality: 85, Quality: 85,
Grayscale: true, Grayscale: true,
Crop: true, Crop: true,
CropRatioLeft: 1, CropRatioLeft: 1,
CropRatioUp: 1, CropRatioUp: 1,
CropRatioRight: 1, CropRatioRight: 1,
CropRatioBottom: 3, CropRatioBottom: 3,
NoBlankImage: true, NoBlankImage: true,
HasCover: true, HasCover: true,
KeepDoublePageIfSplitted: true, KeepDoublePageIfSplit: true,
SortPathMode: 1, SortPathMode: 1,
ForegroundColor: "000", ForegroundColor: "000",
BackgroundColor: "FFF", BackgroundColor: "FFF",
Format: "jpeg", Format: "jpeg",
TitlePage: 1, TitlePage: 1,
profiles: profiles.New(), profiles: profiles.New(),
} }
} }
@ -173,7 +173,7 @@ func (o *Options) MarshalJSON() ([]byte, error) {
if o.PortraitOnly || !o.AppleBookCompatibility { if o.PortraitOnly || !o.AppleBookCompatibility {
out["autosplitdoublepage"] = o.AutoSplitDoublePage out["autosplitdoublepage"] = o.AutoSplitDoublePage
if o.AutoSplitDoublePage { if o.AutoSplitDoublePage {
out["keepdoublepageifsplitted"] = o.KeepDoublePageIfSplitted out["keepdoublepageifsplit"] = o.KeepDoublePageIfSplit
} }
} }
if o.LimitMb != 0 { if o.LimitMb != 0 {
@ -244,7 +244,7 @@ func (o *Options) ShowConfig() string {
case 1: case 1:
titlePage = "always" titlePage = "always"
case 2: case 2:
titlePage = "when epub is splitted" titlePage = "when epub is split"
} }
grayscaleMode := "normal" grayscaleMode := "normal"
@ -265,28 +265,28 @@ func (o *Options) ShowConfig() string {
{"Format", o.Format, true}, {"Format", o.Format, true},
{"Quality", o.Quality, o.Format == "jpeg"}, {"Quality", o.Quality, o.Format == "jpeg"},
{"Grayscale", o.Grayscale, true}, {"Grayscale", o.Grayscale, true},
{"Grayscale Mode", grayscaleMode, o.Grayscale}, {"Grayscale mode", grayscaleMode, o.Grayscale},
{"Crop", o.Crop, true}, {"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}, {"Brightness", o.Brightness, o.Brightness != 0},
{"Contrast", o.Contrast, o.Contrast != 0}, {"Contrast", o.Contrast, o.Contrast != 0},
{"Auto Contrast", o.AutoContrast, true}, {"Auto contrast", o.AutoContrast, true},
{"Auto Rotate", o.AutoRotate, true}, {"Auto rotate", o.AutoRotate, true},
{"Auto Split DoublePage", o.AutoSplitDoublePage, o.PortraitOnly || !o.AppleBookCompatibility}, {"Auto split double page", o.AutoSplitDoublePage, o.PortraitOnly || !o.AppleBookCompatibility},
{"Keep DoublePage If Splitted", o.KeepDoublePageIfSplitted, (o.PortraitOnly || !o.AppleBookCompatibility) && o.AutoSplitDoublePage}, {"Keep double page if split", o.KeepDoublePageIfSplit, (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},
{"Limit", fmt.Sprintf("%d Mb", o.LimitMb), o.LimitMb != 0}, {"Limit", fmt.Sprintf("%d Mb", o.LimitMb), o.LimitMb != 0},
{"Strip First Directory From Toc", o.StripFirstDirectoryFromToc, true}, {"Strip first directory from toc", o.StripFirstDirectoryFromToc, true},
{"Sort Path Mode", sortpathmode, true}, {"Sort path mode", sortpathmode, true},
{"Foreground Color", fmt.Sprintf("#%s", o.ForegroundColor), true}, {"Foreground color", fmt.Sprintf("#%s", o.ForegroundColor), true},
{"Background Color", fmt.Sprintf("#%s", o.BackgroundColor), true}, {"Background color", fmt.Sprintf("#%s", o.BackgroundColor), true},
{"Resize", !o.NoResize, true}, {"Resize", !o.NoResize, true},
{"Aspect Ratio", aspectRatio, true}, {"Aspect ratio", aspectRatio, true},
{"Portrait Only", o.PortraitOnly, true}, {"Portrait only", o.PortraitOnly, true},
{"Title Page", titlePage, true}, {"Title page", titlePage, true},
{"Apple Book Compatibility", o.AppleBookCompatibility, !o.PortraitOnly}, {"Apple book compatibility", o.AppleBookCompatibility, !o.PortraitOnly},
} { } {
if v.Condition { if v.Condition {
b.WriteString(fmt.Sprintf("\n %-32s: %v", v.Key, v.Value)) b.WriteString(fmt.Sprintf("\n %-32s: %v", v.Key, v.Value))

View File

@ -445,7 +445,7 @@ 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 && if !e.Image.View.PortraitOnly &&
(img.DoublePage || (img.DoublePage ||
(!e.Image.KeepDoublePageIfSplitted && img.Part == 1) || (!e.Image.KeepDoublePageIfSplit && img.Part == 1) ||
(img.Part == 0 && img == lastImage)) { (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

View File

@ -82,7 +82,7 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
// do not keep double page if requested // do not keep double page if requested
if !(img.DoublePage && input.Id > 0 && 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 { if err = imgStorage.Add(img.EPUBImgPath(), img.Raw, 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)

View File

@ -22,23 +22,23 @@ type View struct {
} }
type Image struct { type Image struct {
Crop *Crop Crop *Crop
Quality int Quality int
Brightness int Brightness int
Contrast int Contrast int
AutoContrast bool AutoContrast bool
AutoRotate bool AutoRotate bool
AutoSplitDoublePage bool AutoSplitDoublePage bool
KeepDoublePageIfSplitted bool KeepDoublePageIfSplit bool
NoBlankImage bool NoBlankImage bool
Manga bool Manga bool
HasCover bool HasCover bool
View *View View *View
GrayScale bool GrayScale bool
GrayScaleMode int GrayScaleMode int
Resize bool Resize bool
Format string Format string
AppleBookCompatibility bool AppleBookCompatibility bool
} }
type Options struct { type Options struct {

View File

@ -180,7 +180,7 @@ func getManifest(o *ContentOptions) []tag {
img, img,
!o.ImageOptions.View.PortraitOnly && !o.ImageOptions.View.PortraitOnly &&
(img.DoublePage || (img.DoublePage ||
(!o.ImageOptions.KeepDoublePageIfSplitted && img.Part == 1) || (!o.ImageOptions.KeepDoublePageIfSplit && img.Part == 1) ||
(img.Part == 0 && img == lastImage))) (img.Part == 0 && img == lastImage)))
} }

34
main.go
View File

@ -122,23 +122,23 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
Quiet: cmd.Options.Quiet, Quiet: cmd.Options.Quiet,
Json: cmd.Options.Json, Json: cmd.Options.Json,
Image: &epuboptions.Image{ 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}, 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, Quality: cmd.Options.Quality,
Brightness: cmd.Options.Brightness, Brightness: cmd.Options.Brightness,
Contrast: cmd.Options.Contrast, Contrast: cmd.Options.Contrast,
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, KeepDoublePageIfSplit: cmd.Options.KeepDoublePageIfSplit,
NoBlankImage: cmd.Options.NoBlankImage, NoBlankImage: cmd.Options.NoBlankImage,
Manga: cmd.Options.Manga, Manga: cmd.Options.Manga,
HasCover: cmd.Options.HasCover, 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}}, 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, GrayScale: cmd.Options.Grayscale,
GrayScaleMode: cmd.Options.GrayscaleMode, GrayScaleMode: cmd.Options.GrayscaleMode,
Resize: !cmd.Options.NoResize, Resize: !cmd.Options.NoResize,
Format: cmd.Options.Format, Format: cmd.Options.Format,
AppleBookCompatibility: cmd.Options.AppleBookCompatibility, AppleBookCompatibility: cmd.Options.AppleBookCompatibility,
}, },
}).Write(); err != nil { }).Write(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err) fmt.Fprintf(os.Stderr, "Error: %v\n", err)