From f0673b8f585e2963b542998aba16671a4ffa1caa Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Mon, 16 Jan 2023 08:46:32 +0100 Subject: [PATCH] remove blank page for double page rendering --- README.md | 2 ++ internal/epub/core.go | 5 +++-- internal/epub/templates/content.opf.tmpl | 15 +++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 57a11bb..672647e 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ Usage of go-comic-converter: Limit size of the ePub: Default nolimit (0), Minimum 20 -manga Manga mode (right to left) + -noblankpage + Remove blank pages -nocrop Disable cropping -output string diff --git a/internal/epub/core.go b/internal/epub/core.go index 41a3cf5..5cf21fe 100644 --- a/internal/epub/core.go +++ b/internal/epub/core.go @@ -23,6 +23,7 @@ type ImageOptions struct { Contrast int AutoRotate bool AutoSplitDoublePage bool + NoBlankPage bool Manga bool Workers int } @@ -73,7 +74,7 @@ func NewEpub(options *EpubOptions) *ePub { return }, "spread_blank": func(part int) bool { - if part == 1 && spreadRight == options.Manga { + if !options.NoBlankPage && part == 1 && spreadRight == options.Manga { return true } return false @@ -216,7 +217,7 @@ func (e *ePub) Write() error { return err } - if img.Part == 1 { + if !e.NoBlankPage && img.Part == 1 { if err := wz.WriteFile( fmt.Sprintf("OEBPS/Text/%d_sp.xhtml", img.Id), e.render(blankTmpl, map[string]any{ diff --git a/internal/epub/templates/content.opf.tmpl b/internal/epub/templates/content.opf.tmpl index a1855cb..6a59158 100644 --- a/internal/epub/templates/content.opf.tmpl +++ b/internal/epub/templates/content.opf.tmpl @@ -1,17 +1,18 @@ +{{ $info := .Info }} -{{ .Info.Title }} +{{ $info.Title }} en-US -urn:uuid:{{ .Info.UID }} +urn:uuid:{{ $info.UID }} GO Comic Converter GO Comic Converter -{{ .Info.UpdatedAt }} +{{ $info.UpdatedAt }} - + - + @@ -28,12 +29,14 @@ {{ range .Images }} +{{ if eq $info.NoBlankPage false }} {{ if eq .Part 1 }} {{ end }} {{ end }} +{{ end }} - + {{ range .Images }} {{ if spread_blank .Part }}