mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-06-29 00:29:55 +02:00
fix typo & grammar
This commit is contained in:
parent
2d15bc43c2
commit
b6db09aa9e
14
README.md
14
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
Convert CBZ/CBR/Dir into EPUB for e-reader devices (Kindle Devices, ...)
|
||||
|
||||
My goal is to make a simple, crossplatform, and fast tool to convert comics into EPUB.
|
||||
My goal is to make a simple, cross-platform, and fast tool to convert comics into EPUB.
|
||||
|
||||
EPUB is now support by Amazon through [SendToKindle](https://www.amazon.com/gp/sendtokindle/), by Email or by using the App. So I've made it simple to support the size limit constraint of those services.
|
||||
|
||||
@ -16,7 +16,7 @@ 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
|
||||
- Keep double page if split
|
||||
- Remove blank image (empty image is removed)
|
||||
- Manga or Normal mode
|
||||
- Support cover page or not (first page will be taken in that case)
|
||||
@ -91,7 +91,7 @@ Convert every supported image files found in the input directory:
|
||||
$ go-comic-converter -profile SR -input ~/Download/MyComic
|
||||
```
|
||||
|
||||
By default it will output: ~/Download/MyComic.epub
|
||||
By default, it will output: ~/Download/MyComic.epub
|
||||
|
||||
## Convert CBZ, ZIP, CBR, RAR, PDF
|
||||
|
||||
@ -101,7 +101,7 @@ Convert every supported image files found in the input directory:
|
||||
$ go-comic-converter -profile SR -input ~/Download/MyComic.[CBZ,ZIP,CBR,RAR,PDF]
|
||||
```
|
||||
|
||||
By default it will output: ~/Download/MyComic.epub
|
||||
By default, it will output: ~/Download/MyComic.epub
|
||||
|
||||
## Convert with size limit
|
||||
|
||||
@ -130,7 +130,7 @@ If the total is above 1, then the title of the EPUB include:
|
||||
|
||||
## Dry run
|
||||
|
||||
If you want to preview what will be set during the convertion without running the conversion, then you can use the `-dry` option.
|
||||
If you want to preview what will be set during the conversion without running the conversion, then you can use the `-dry` option.
|
||||
|
||||
```
|
||||
$ go-comic-converter -input ~/Downloads/mymanga.cbr -profile SR -auto -manga -limitmb 200 -dry
|
||||
@ -176,7 +176,7 @@ TOC:
|
||||
|
||||
## Dry verbose
|
||||
|
||||
You can choose different way to sort path and files, depending of your source. You can preview the sorted result with the option `dry-verbose` associated with `dry`.
|
||||
You can choose different way to sort path and files, depending on your source. You can preview the sorted result with the option `dry-verbose` associated with `dry`.
|
||||
|
||||
The option `sort` allow you to change the sorting order.
|
||||
|
||||
@ -418,7 +418,7 @@ Explanation:
|
||||
- `-autocontrast`: automatically improve contrast
|
||||
- `-manga`: manga mode, read right to left
|
||||
- `-limitmb 200`: size limit to 200MB allowing upload from SendToKindle website
|
||||
- `-strip`: remove first level if alone on TOC, as offen comics include a main directory with the title
|
||||
- `-strip`: remove first level if alone on TOC, as often comics include a main directory with the title
|
||||
- `aspect-ratio`: ensure aspect ratio is 1:1.6, best for kindle devices.
|
||||
# Help
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
/*
|
||||
Converter Helper to parse and prepare options for go-comic-converter.
|
||||
|
||||
It use goflag with additional feature:
|
||||
- Keep original order
|
||||
- Support section
|
||||
*/
|
||||
// Package converter Helper to parse and prepare options for go-comic-converter.
|
||||
//
|
||||
// It uses goflag with additional feature:
|
||||
// - Keep original order
|
||||
// - Support section
|
||||
package converter
|
||||
|
||||
import (
|
||||
@ -97,7 +95,7 @@ func (c *Converter) AddBoolParam(p *bool, name string, value bool, usage string)
|
||||
c.order = append(c.order, converterOrderName{value: name})
|
||||
}
|
||||
|
||||
// Initialize the parser with all section and parameter.
|
||||
// InitParse Initialize the parser with all section and parameter.
|
||||
func (c *Converter) InitParse() {
|
||||
c.AddSection("Output")
|
||||
c.AddStringParam(&c.Options.Input, "input", "", "Source of comic to convert: directory, cbz, zip, cbr, rar, pdf")
|
||||
@ -115,25 +113,25 @@ func (c *Converter) InitParse() {
|
||||
c.AddIntParam(&c.Options.CropRatioUp, "crop-ratio-up", c.Options.CropRatioUp, "Crop ratio up: ratio of pixels allow to be non blank while cutting on the top.")
|
||||
c.AddIntParam(&c.Options.CropRatioRight, "crop-ratio-right", c.Options.CropRatioRight, "Crop ratio right: ratio of pixels allow to be non blank while cutting on the right.")
|
||||
c.AddIntParam(&c.Options.CropRatioBottom, "crop-ratio-bottom", c.Options.CropRatioBottom, "Crop ratio bottom: ratio of pixels allow to be non blank while cutting on the bottom.")
|
||||
c.AddIntParam(&c.Options.Brightness, "brightness", c.Options.Brightness, "Brightness readjustement: between -100 and 100, > 0 lighter, < 0 darker")
|
||||
c.AddIntParam(&c.Options.Contrast, "contrast", c.Options.Contrast, "Contrast readjustement: between -100 and 100, > 0 more contrast, < 0 less contrast")
|
||||
c.AddIntParam(&c.Options.Brightness, "brightness", c.Options.Brightness, "Brightness readjustment: between -100 and 100, > 0 lighter, < 0 darker")
|
||||
c.AddIntParam(&c.Options.Contrast, "contrast", c.Options.Contrast, "Contrast readjustment: between -100 and 100, > 0 more contrast, < 0 less contrast")
|
||||
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.KeepDoublePageIfSplitted, "keepdoublepageifsplitted", c.Options.KeepDoublePageIfSplitted, "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.")
|
||||
c.AddIntParam(&c.Options.LimitMb, "limitmb", c.Options.LimitMb, "Limit size of the EPUB: Default nolimit (0), Minimum 20")
|
||||
c.AddBoolParam(&c.Options.StripFirstDirectoryFromToc, "strip", c.Options.StripFirstDirectoryFromToc, "Strip first directory from the TOC if only 1")
|
||||
c.AddIntParam(&c.Options.SortPathMode, "sort", c.Options.SortPathMode, "Sort path mode\n0 = alpha for path and file\n1 = alphanum for path and alpha for file\n2 = alphanum for path and file")
|
||||
c.AddStringParam(&c.Options.ForegroundColor, "foreground-color", c.Options.ForegroundColor, "Foreground color in hexa format RGB. Black=000, White=FFF")
|
||||
c.AddStringParam(&c.Options.BackgroundColor, "background-color", c.Options.BackgroundColor, "Background color in hexa format RGB. Black=000, White=FFF, Light Gray=DDD, Dark Gray=777")
|
||||
c.AddIntParam(&c.Options.SortPathMode, "sort", c.Options.SortPathMode, "Sort path mode\n0 = alpha for path and file\n1 = alphanumeric for path and alpha for file\n2 = alphanumeric for path and file")
|
||||
c.AddStringParam(&c.Options.ForegroundColor, "foreground-color", c.Options.ForegroundColor, "Foreground color in hexadecimal format RGB. Black=000, White=FFF")
|
||||
c.AddStringParam(&c.Options.BackgroundColor, "background-color", c.Options.BackgroundColor, "Background color in hexadecimal format RGB. Black=000, White=FFF, Light Gray=DDD, Dark Gray=777")
|
||||
c.AddBoolParam(&c.Options.NoResize, "noresize", c.Options.NoResize, "Do not reduce image size if exceed device size")
|
||||
c.AddStringParam(&c.Options.Format, "format", c.Options.Format, "Format of output images: jpeg (lossy), png (lossless)")
|
||||
c.AddFloatParam(&c.Options.AspectRatio, "aspect-ratio", c.Options.AspectRatio, "Aspect ratio (height/width) of the output\n -1 = same as device\n 0 = same as source\n1.6 = amazon advice for kindle")
|
||||
c.AddBoolParam(&c.Options.PortraitOnly, "portrait-only", c.Options.PortraitOnly, "Portrait only: force orientation to portrait only.")
|
||||
c.AddIntParam(&c.Options.TitlePage, "titlepage", c.Options.TitlePage, "Title page\n0 = never\n1 = always\n2 = only if epub is splitted")
|
||||
c.AddIntParam(&c.Options.TitlePage, "titlepage", c.Options.TitlePage, "Title page\n0 = never\n1 = always\n2 = only if epub is split")
|
||||
|
||||
c.AddSection("Default config")
|
||||
c.AddBoolParam(&c.Options.Show, "show", false, "Show your default parameters")
|
||||
@ -363,11 +361,11 @@ func (c *Converter) Validate() error {
|
||||
// Color
|
||||
colorRegex := regexp.MustCompile("^[0-9A-F]{3}$")
|
||||
if !colorRegex.MatchString(c.Options.ForegroundColor) {
|
||||
return errors.New("foreground color must have color format in hexa: [0-9A-F]{3}")
|
||||
return errors.New("foreground color must have color format in hexadecimal: [0-9A-F]{3}")
|
||||
}
|
||||
|
||||
if !colorRegex.MatchString(c.Options.BackgroundColor) {
|
||||
return errors.New("background color must have color format in hexa: [0-9A-F]{3}")
|
||||
return errors.New("background color must have color format in hexadecimal: [0-9A-F]{3}")
|
||||
}
|
||||
|
||||
// Format
|
||||
|
@ -225,9 +225,9 @@ func (o *Options) ShowConfig() string {
|
||||
case 0:
|
||||
sortpathmode = "path=alpha, file=alpha"
|
||||
case 1:
|
||||
sortpathmode = "path=alphanum, file=alpha"
|
||||
sortpathmode = "path=alphanumeric, file=alpha"
|
||||
case 2:
|
||||
sortpathmode = "path=alphanum, file=alphanum"
|
||||
sortpathmode = "path=alphanumeric, file=alphanumeric"
|
||||
}
|
||||
|
||||
aspectRatio := "auto"
|
||||
@ -301,7 +301,7 @@ func (o *Options) ResetConfig() error {
|
||||
return o.LoadConfig()
|
||||
}
|
||||
|
||||
// save all current settings as futur default value
|
||||
// SaveConfig save all current settings as default value
|
||||
func (o *Options) SaveConfig() error {
|
||||
f, err := os.Create(o.FileName())
|
||||
if err != nil {
|
||||
|
@ -20,7 +20,7 @@ type Profiles []Profile
|
||||
// Initialize list of all supported profiles.
|
||||
func New() Profiles {
|
||||
return []Profile{
|
||||
// High Resolution for Tablette
|
||||
// High Resolution for Tablet
|
||||
{"HR", "High Resolution", 2400, 3840},
|
||||
{"SR", "Standard Resolution", 1200, 1920},
|
||||
//Kindle
|
||||
|
@ -25,27 +25,27 @@ type Image struct {
|
||||
Error error
|
||||
}
|
||||
|
||||
// key name of the blank plage after the image
|
||||
// SpaceKey key name of the blank page after the image
|
||||
func (i *Image) SpaceKey() string {
|
||||
return fmt.Sprintf("space_%d", i.Id)
|
||||
}
|
||||
|
||||
// path of the blank page
|
||||
// SpacePath path of the blank page
|
||||
func (i *Image) SpacePath() string {
|
||||
return fmt.Sprintf("Text/%s.xhtml", i.SpaceKey())
|
||||
}
|
||||
|
||||
// path of the blank page into the EPUB
|
||||
// EPUBSpacePath path of the blank page into the EPUB
|
||||
func (i *Image) EPUBSpacePath() string {
|
||||
return fmt.Sprintf("OEBPS/%s", i.SpacePath())
|
||||
}
|
||||
|
||||
// key for page
|
||||
// PageKey key for page
|
||||
func (i *Image) PageKey() string {
|
||||
return fmt.Sprintf("page_%d_p%d", i.Id, i.Part)
|
||||
}
|
||||
|
||||
// page path linked to the image
|
||||
// PagePath page path linked to the image
|
||||
func (i *Image) PagePath() string {
|
||||
return fmt.Sprintf("Text/%s.xhtml", i.PageKey())
|
||||
}
|
||||
@ -70,10 +70,10 @@ func (i *Image) EPUBImgPath() string {
|
||||
return fmt.Sprintf("OEBPS/%s", i.ImgPath())
|
||||
}
|
||||
|
||||
// style to apply to the image.
|
||||
// ImgStyle style to apply to the image.
|
||||
//
|
||||
// center by default.
|
||||
// align to left or right if it's part of the splitted double page.
|
||||
// align to left or right if it's part of the split double page.
|
||||
func (i *Image) ImgStyle(viewWidth, viewHeight int, align string) string {
|
||||
relWidth, relHeight := i.RelSize(viewWidth, viewHeight)
|
||||
marginW, marginH := float64(viewWidth-relWidth)/2, float64(viewHeight-relHeight)/2
|
||||
|
@ -78,7 +78,7 @@ func (f *autocontrast) Draw(dst draw.Image, src image.Image, options *gift.Optio
|
||||
// compute a curve from dark and light factor applying to the color
|
||||
c := (1 - d) + (d+l)*y
|
||||
|
||||
// applying the coef
|
||||
// applying the ratio
|
||||
return f.cap(r0 * c), f.cap(g0 * c), f.cap(b0 * c), a0
|
||||
}).Draw(dst, src, options)
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// dry run, skip convertion
|
||||
// dry run, skip conversion
|
||||
if e.Dry {
|
||||
for img := range imageInput {
|
||||
images = append(images, &epubimage.Image{
|
||||
|
@ -30,7 +30,9 @@ type tag struct {
|
||||
value string
|
||||
}
|
||||
|
||||
// create the content file
|
||||
// Content create the content file
|
||||
//
|
||||
//goland:noinspection HttpUrlsUsage,HttpUrlsUsage,HttpUrlsUsage,HttpUrlsUsage
|
||||
func Content(o *ContentOptions) string {
|
||||
doc := etree.NewDocument()
|
||||
doc.CreateProcInst("xml", `version="1.0" encoding="UTF-8"`)
|
||||
@ -269,7 +271,7 @@ func getSpinePortrait(o *ContentOptions) []tag {
|
||||
return spine
|
||||
}
|
||||
|
||||
// guide part of the content
|
||||
// getGuide Section guide of the content
|
||||
func getGuide(o *ContentOptions) []tag {
|
||||
return []tag{
|
||||
{"reference", tagAttrs{"type": "cover", "title": "cover", "href": "Text/cover.xhtml"}, ""},
|
||||
|
@ -8,7 +8,9 @@ import (
|
||||
epubimage "github.com/celogeek/go-comic-converter/v2/internal/epub/image"
|
||||
)
|
||||
|
||||
// create toc
|
||||
// Toc create toc
|
||||
//
|
||||
//goland:noinspection HttpUrlsUsage
|
||||
func Toc(title string, hasTitle bool, stripFirstDirectoryFromToc bool, images []*epubimage.Image) string {
|
||||
doc := etree.NewDocument()
|
||||
doc.CreateProcInst("xml", `version="1.0" encoding="UTF-8"`)
|
||||
|
@ -32,7 +32,7 @@ type node struct {
|
||||
Children []*node
|
||||
}
|
||||
|
||||
// initilize tree with a root node
|
||||
// New initialize tree with a root node
|
||||
func New() *tree {
|
||||
return &tree{map[string]*node{
|
||||
".": {".", []*node{}},
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
sortpath support sorting of path that may include number.
|
||||
Package sortpath support sorting of path that may include number.
|
||||
|
||||
A series of path can looks like:
|
||||
A series of path can look like:
|
||||
- Tome1/Chap1/Image1.jpg
|
||||
- Tome1/Chap2/Image1.jpg
|
||||
- Tome1/Chap10/Image2.jpg
|
||||
@ -11,8 +11,8 @@ and compare them by decomposing the string and number part.
|
||||
|
||||
The module support 3 mode:
|
||||
- mode=0 alpha for path and file
|
||||
- mode=1 alphanum for path and alpha for file
|
||||
- mode=2 alphanum for path and file
|
||||
- mode=1 alphanumeric for path and alpha for file
|
||||
- mode=2 alphanumeric for path and file
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -43,8 +43,8 @@ func parsePart(p string) part {
|
||||
}
|
||||
|
||||
// mode=0 alpha for path and file
|
||||
// mode=1 alphanum for path and alpha for file
|
||||
// mode=2 alphanum for path and file
|
||||
// mode=1 alphanumeric for path and alpha for file
|
||||
// mode=2 alphanumeric for path and file
|
||||
func parse(filename string, mode int) []part {
|
||||
pathname, name := filepath.Split(strings.ToLower(filename))
|
||||
pathname = strings.TrimSuffix(pathname, string(filepath.Separator))
|
||||
@ -53,13 +53,13 @@ func parse(filename string, mode int) []part {
|
||||
|
||||
f := []part{}
|
||||
for _, p := range strings.Split(pathname, string(filepath.Separator)) {
|
||||
if mode > 0 { // alphanum for path
|
||||
if mode > 0 { // alphanumeric for path
|
||||
f = append(f, parsePart(p))
|
||||
} else {
|
||||
f = append(f, part{p, p, 0})
|
||||
}
|
||||
}
|
||||
if mode == 2 { // alphanum for file
|
||||
if mode == 2 { // alphanumeric for file
|
||||
f = append(f, parsePart(name))
|
||||
} else {
|
||||
f = append(f, part{name, name, 0})
|
||||
@ -67,7 +67,7 @@ func parse(filename string, mode int) []part {
|
||||
return f
|
||||
}
|
||||
|
||||
// compare 2 fullpath splitted into parts
|
||||
// compare 2 full path split into parts
|
||||
func compareParts(a, b []part) float64 {
|
||||
m := len(a)
|
||||
if m > len(b) {
|
||||
|
2
main.go
2
main.go
@ -1,7 +1,7 @@
|
||||
/*
|
||||
Convert CBZ/CBR/Dir into EPUB for e-reader devices (Kindle Devices, ...)
|
||||
|
||||
My goal is to make a simple, crossplatform, and fast tool to convert comics into EPUB.
|
||||
My goal is to make a simple, cross-platform, and fast tool to convert comics into EPUB.
|
||||
|
||||
EPUB is now support by Amazon through [SendToKindle](https://www.amazon.com/gp/sendtokindle/), by Email or by using the App. So I've made it simple to support the size limit constraint of those services.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user