mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 16:22:37 +02:00
Compare commits
No commits in common. "cd73416a5c52293c9d978f72cc883bff363a9994" and "56917987ae8f296d2dad60034bf063deca611d29" have entirely different histories.
cd73416a5c
...
56917987ae
12
README.md
12
README.md
@ -16,7 +16,6 @@ EPUB is now support by Amazon through [SendToKindle](https://www.amazon.com/gp/s
|
||||
- Auto contrast
|
||||
- Auto rotate (if reader mainly read on portrait)
|
||||
- Auto split double page (for easy read on portrait)
|
||||
- Keep double page if splitted
|
||||
- Remove blank image (empty image is removed)
|
||||
- Manga or Normal mode
|
||||
- Support cover page or not (first page will be taken in that case)
|
||||
@ -150,7 +149,6 @@ Options:
|
||||
AutoContrast : true
|
||||
AutoRotate : false
|
||||
AutoSplitDoublePage : false
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : true
|
||||
HasCover : true
|
||||
@ -197,7 +195,6 @@ Options:
|
||||
AutoContrast : true
|
||||
AutoRotate : false
|
||||
AutoSplitDoublePage : false
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : true
|
||||
HasCover : true
|
||||
@ -254,7 +251,6 @@ Options:
|
||||
AutoContrast : false
|
||||
AutoRotate : false
|
||||
AutoSplitDoublePage : false
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : false
|
||||
HasCover : true
|
||||
@ -285,7 +281,6 @@ Options:
|
||||
AutoContrast : true
|
||||
AutoRotate : true
|
||||
AutoSplitDoublePage : true
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : true
|
||||
HasCover : true
|
||||
@ -317,7 +312,6 @@ Options:
|
||||
AutoContrast : true
|
||||
AutoRotate : true
|
||||
AutoSplitDoublePage : true
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : false
|
||||
HasCover : true
|
||||
@ -352,7 +346,6 @@ Options:
|
||||
AutoContrast : false
|
||||
AutoRotate : false
|
||||
AutoSplitDoublePage : false
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : false
|
||||
HasCover : true
|
||||
@ -387,7 +380,6 @@ Options:
|
||||
AutoContrast : true
|
||||
AutoRotate : false
|
||||
AutoSplitDoublePage : false
|
||||
KeepDoublePageIfSplitted : true
|
||||
NoBlankImage : true
|
||||
Manga : true
|
||||
HasCover : true
|
||||
@ -430,7 +422,7 @@ Output:
|
||||
|
||||
Config:
|
||||
-profile string (default "SR")
|
||||
Profile to use:
|
||||
Profile to use:
|
||||
- HR ( 2400x3840 ) - High Resolution
|
||||
- SR ( 1200x1920 ) - Standard Resolution
|
||||
- K1 ( 600x670 ) - Kindle 1
|
||||
@ -488,8 +480,6 @@ Config:
|
||||
Auto Rotate page when width > height
|
||||
-autosplitdoublepage
|
||||
Auto Split double page when width > height
|
||||
-keepdoublepageifsplitted (default true)
|
||||
Keep the double page if splitted
|
||||
-noblankimage (default true)
|
||||
Remove blank image
|
||||
-manga
|
||||
|
8
go.mod
8
go.mod
@ -12,7 +12,7 @@ require (
|
||||
github.com/raff/pdfreader v0.0.0-20220308062436-033e8ac577f0
|
||||
github.com/schollz/progressbar/v3 v3.13.1
|
||||
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e
|
||||
golang.org/x/image v0.12.0
|
||||
golang.org/x/image v0.11.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@ -24,7 +24,7 @@ require (
|
||||
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
golang.org/x/net v0.15.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/term v0.12.0 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/term v0.11.0 // indirect
|
||||
)
|
||||
|
18
go.sum
18
go.sum
@ -46,16 +46,16 @@ github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkT
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/image v0.12.0 h1:w13vZbU4o5rKOFFR8y7M+c4A5jXDC0uXTdHYRP8X2DQ=
|
||||
golang.org/x/image v0.12.0/go.mod h1:Lu90jvHG7GfemOIcldsh9A2hS01ocl6oNO7ype5mEnk=
|
||||
golang.org/x/image v0.11.0 h1:ds2RoQvBvYTiJkwpSFDwCcDFNX7DqjL2WsUgTNk0Ooo=
|
||||
golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -67,19 +67,19 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
|
||||
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
|
@ -119,7 +119,6 @@ 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 splitted")
|
||||
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.")
|
||||
|
@ -35,7 +35,6 @@ 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"`
|
||||
NoBlankImage bool `yaml:"no_blank_image"`
|
||||
Manga bool `yaml:"manga"`
|
||||
HasCover bool `yaml:"has_cover"`
|
||||
@ -78,23 +77,22 @@ 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,
|
||||
SortPathMode: 1,
|
||||
ForegroundColor: "000",
|
||||
BackgroundColor: "FFF",
|
||||
Format: "jpeg",
|
||||
TitlePage: 1,
|
||||
profiles: profiles.New(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +208,6 @@ func (o *Options) ShowConfig() string {
|
||||
{"AutoContrast", o.AutoContrast, true},
|
||||
{"AutoRotate", o.AutoRotate, true},
|
||||
{"AutoSplitDoublePage", o.AutoSplitDoublePage, true},
|
||||
{"KeepDoublePageIfSplitted", o.KeepDoublePageIfSplitted, o.AutoSplitDoublePage},
|
||||
{"NoBlankImage", o.NoBlankImage, true},
|
||||
{"Manga", o.Manga, true},
|
||||
{"HasCover", o.HasCover, true},
|
||||
|
@ -442,10 +442,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) ||
|
||||
(img.Part == 0 && img == lastImage)) {
|
||||
if !e.Image.View.PortraitOnly && (img.DoublePage || (img.Part == 0 && img == lastImage)) {
|
||||
if err := e.writeBlank(wz, img); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -101,14 +101,6 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err 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 {
|
||||
bar.Close()
|
||||
fmt.Fprintf(os.Stderr, "error with %s: %s", input.Name, err)
|
||||
|
@ -22,22 +22,21 @@ 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
|
||||
Crop *Crop
|
||||
Quality int
|
||||
Brightness int
|
||||
Contrast int
|
||||
AutoContrast bool
|
||||
AutoRotate bool
|
||||
AutoSplitDoublePage bool
|
||||
NoBlankImage bool
|
||||
Manga bool
|
||||
HasCover bool
|
||||
View *View
|
||||
GrayScale bool
|
||||
GrayScaleMode int
|
||||
Resize bool
|
||||
Format string
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
|
@ -174,12 +174,7 @@ func getManifest(o *ContentOptions) []tag {
|
||||
|
||||
lastImage := o.Images[len(o.Images)-1]
|
||||
for _, img := range o.Images {
|
||||
addTag(
|
||||
img,
|
||||
!o.ImageOptions.View.PortraitOnly &&
|
||||
(img.DoublePage ||
|
||||
(!o.ImageOptions.KeepDoublePageIfSplitted && img.Part == 1) ||
|
||||
(img.Part == 0 && img == lastImage)))
|
||||
addTag(img, !o.ImageOptions.View.PortraitOnly && (img.DoublePage || (img.Part == 0 && img == lastImage)))
|
||||
}
|
||||
|
||||
items = append(items, imageTags...)
|
||||
@ -217,7 +212,7 @@ func getSpineAuto(o *ContentOptions) []tag {
|
||||
)
|
||||
}
|
||||
for _, img := range o.Images {
|
||||
if (img.DoublePage || img.Part == 1) && o.ImageOptions.Manga == isOnTheRight {
|
||||
if img.DoublePage && o.ImageOptions.Manga == isOnTheRight {
|
||||
spine = append(spine, tag{
|
||||
"itemref",
|
||||
tagAttrs{"idref": img.SpaceKey(), "properties": getSpreadBlank()},
|
||||
|
31
main.go
31
main.go
@ -114,22 +114,21 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
||||
DryVerbose: cmd.Options.DryVerbose,
|
||||
Quiet: cmd.Options.Quiet,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
},
|
||||
}).Write(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user