change Epub, epub to EPUB in code and comment

This commit is contained in:
Celogeek 2023-04-29 11:55:13 +02:00
parent 8cf02445e7
commit b71deb257a
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
8 changed files with 37 additions and 37 deletions

View File

@ -90,9 +90,9 @@ func (c *Converter) AddBoolParam(p *bool, name string, value bool, usage string)
func (c *Converter) InitParse() {
c.AddSection("Output")
c.AddStringParam(&c.Options.Input, "input", "", "Source of comic to convert: directory, cbz, zip, cbr, rar, pdf")
c.AddStringParam(&c.Options.Output, "output", "", "Output of the epub (directory or epub): (default [INPUT].epub)")
c.AddStringParam(&c.Options.Author, "author", "GO Comic Converter", "Author of the epub")
c.AddStringParam(&c.Options.Title, "title", "", "Title of the epub")
c.AddStringParam(&c.Options.Output, "output", "", "Output of the EPUB (directory or EPUB): (default [INPUT].epub)")
c.AddStringParam(&c.Options.Author, "author", "GO Comic Converter", "Author of the EPUB")
c.AddStringParam(&c.Options.Title, "title", "", "Title of the EPUB")
c.AddSection("Config")
c.AddStringParam(&c.Options.Profile, "profile", c.Options.Profile, fmt.Sprintf("Profile to use: \n%s", c.Options.AvailableProfiles()))
@ -110,7 +110,7 @@ func (c *Converter) InitParse() {
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.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")

View File

@ -1,5 +1,5 @@
/*
Tools to create epub from images.
Tools to create EPUB from images.
*/
package epub
@ -30,7 +30,7 @@ type ePub struct {
UpdatedAt string
templateProcessor *template.Template
imageProcessor *epubimageprocessor.EpubImageProcessor
imageProcessor *epubimageprocessor.EPUBImageProcessor
}
type epubPart struct {
@ -38,7 +38,7 @@ type epubPart struct {
LoadedImages epubimageprocessor.LoadedImages
}
// initialize epub
// initialize EPUB
func New(options *epuboptions.Options) *ePub {
uid := uuid.Must(uuid.NewV4())
tmpl := template.New("parser")
@ -68,7 +68,7 @@ func (e *ePub) render(templateString string, data map[string]any) string {
}
// write image to the zip
func (e *ePub) writeImage(wz *epubzip.EpubZip, img *epubimageprocessor.LoadedImage) error {
func (e *ePub) writeImage(wz *epubzip.EPUBZip, img *epubimageprocessor.LoadedImage) error {
err := wz.WriteContent(
fmt.Sprintf("OEBPS/%s", img.Image.PagePath()),
[]byte(e.render(epubtemplates.Text, map[string]any{
@ -87,7 +87,7 @@ func (e *ePub) writeImage(wz *epubzip.EpubZip, img *epubimageprocessor.LoadedIma
}
// write blank page
func (e *ePub) writeBlank(wz *epubzip.EpubZip, img *epubimage.Image) error {
func (e *ePub) writeBlank(wz *epubzip.EPUBZip, img *epubimage.Image) error {
return wz.WriteContent(
fmt.Sprintf("OEBPS/%s", img.SpacePath()),
[]byte(e.render(epubtemplates.Blank, map[string]any{
@ -127,7 +127,7 @@ func (e *ePub) getParts() ([]*epubPart, error) {
return parts, nil
}
// compute size of the epub part and try to be as close as possible of the target
// compute size of the EPUB part and try to be as close as possible of the target
maxSize := uint64(e.LimitMb * 1024 * 1024)
xhtmlSize := uint64(1024)
// descriptor files + title

View File

@ -31,16 +31,16 @@ func (l LoadedImages) Images() []*epubimage.Image {
return res
}
type EpubImageProcessor struct {
type EPUBImageProcessor struct {
*epuboptions.Options
}
func New(o *epuboptions.Options) *EpubImageProcessor {
return &EpubImageProcessor{o}
func New(o *epuboptions.Options) *EPUBImageProcessor {
return &EPUBImageProcessor{o}
}
// extract and convert images
func (e *EpubImageProcessor) Load() (LoadedImages, error) {
func (e *EPUBImageProcessor) Load() (LoadedImages, error) {
images := make(LoadedImages, 0)
imageCount, imageInput, err := e.load()
@ -135,7 +135,7 @@ func (e *EpubImageProcessor) Load() (LoadedImages, error) {
// transform image into 1 or 3 images
// only doublepage with autosplit has 3 versions
func (e *EpubImageProcessor) transformImage(src image.Image, srcId int) []image.Image {
func (e *EPUBImageProcessor) transformImage(src image.Image, srcId int) []image.Image {
var filters, splitFilter []gift.Filter
var images []image.Image
@ -220,7 +220,7 @@ func (e *EpubImageProcessor) transformImage(src image.Image, srcId int) []image.
}
// create a title page with the cover
func (e *EpubImageProcessor) CoverTitleData(img image.Image, title string) *epubzip.ZipImage {
func (e *EPUBImageProcessor) CoverTitleData(img image.Image, title string) *epubzip.ZipImage {
// Create a blur version of the cover
g := gift.New(epubimagefilters.CoverTitle(title))
dst := image.NewGray(g.Bounds(img.Bounds()))

View File

@ -34,7 +34,7 @@ type tasks struct {
var errNoImagesFound = errors.New("no images found")
// only accept jpg, png and webp as source file
func (e *EpubImageProcessor) isSupportedImage(path string) bool {
func (e *EPUBImageProcessor) isSupportedImage(path string) bool {
switch strings.ToLower(filepath.Ext(path)) {
case ".jpg", ".jpeg", ".png", ".webp":
{
@ -45,7 +45,7 @@ func (e *EpubImageProcessor) isSupportedImage(path string) bool {
}
// Load images from input
func (e *EpubImageProcessor) load() (totalImages int, output chan *tasks, err error) {
func (e *EPUBImageProcessor) load() (totalImages int, output chan *tasks, err error) {
fi, err := os.Stat(e.Input)
if err != nil {
return
@ -70,7 +70,7 @@ func (e *EpubImageProcessor) load() (totalImages int, output chan *tasks, err er
}
// load a directory of images
func (e *EpubImageProcessor) loadDir() (totalImages int, output chan *tasks, err error) {
func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *tasks, err error) {
images := make([]string, 0)
input := filepath.Clean(e.Input)
@ -160,7 +160,7 @@ func (e *EpubImageProcessor) loadDir() (totalImages int, output chan *tasks, err
}
// load a zip file that include images
func (e *EpubImageProcessor) loadCbz() (totalImages int, output chan *tasks, err error) {
func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *tasks, err error) {
r, err := zip.OpenReader(e.Input)
if err != nil {
return
@ -246,7 +246,7 @@ func (e *EpubImageProcessor) loadCbz() (totalImages int, output chan *tasks, err
}
// load a rar file that include images
func (e *EpubImageProcessor) loadCbr() (totalImages int, output chan *tasks, err error) {
func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *tasks, err error) {
var isSolid bool
files, err := rardecode.List(e.Input)
if err != nil {
@ -363,7 +363,7 @@ func (e *EpubImageProcessor) loadCbr() (totalImages int, output chan *tasks, err
}
// extract image from a pdf
func (e *EpubImageProcessor) loadPdf() (totalImages int, output chan *tasks, err error) {
func (e *EPUBImageProcessor) loadPdf() (totalImages int, output chan *tasks, err error) {
pdf := pdfread.Load(e.Input)
if pdf == nil {
err = fmt.Errorf("can't read pdf")

View File

@ -1,5 +1,5 @@
/*
Options for epub creation.
Options for EPUB creation.
*/
package epuboptions

View File

@ -1,5 +1,5 @@
/*
Templates use to create xml files of the epub.
Templates use to create xml files of the EPUB.
*/
package epubtemplates

View File

@ -1,7 +1,7 @@
/*
Helper to write epub files.
Helper to write EPUB files.
We create a zip with the magic epub mimetype.
We create a zip with the magic EPUB mimetype.
*/
package epubzip
@ -11,23 +11,23 @@ import (
"time"
)
type EpubZip struct {
type EPUBZip struct {
w *os.File
wz *zip.Writer
}
// create a new epub
func New(path string) (*EpubZip, error) {
// create a new EPUB
func New(path string) (*EPUBZip, error) {
w, err := os.Create(path)
if err != nil {
return nil, err
}
wz := zip.NewWriter(w)
return &EpubZip{w, wz}, nil
return &EPUBZip{w, wz}, nil
}
// close compress pipe and file.
func (e *EpubZip) Close() error {
func (e *EPUBZip) Close() error {
if err := e.wz.Close(); err != nil {
return err
}
@ -36,7 +36,7 @@ func (e *EpubZip) Close() error {
// Write mimetype, in a very specific way.
// This will be valid with epubcheck tools.
func (e *EpubZip) WriteMagic() error {
func (e *EPUBZip) WriteMagic() error {
t := time.Now()
fh := &zip.FileHeader{
Name: "mimetype",
@ -59,7 +59,7 @@ func (e *EpubZip) WriteMagic() error {
}
// Write image. They are already compressed, so we write them down directly.
func (e *EpubZip) WriteRaw(raw *ZipImage) error {
func (e *EPUBZip) WriteRaw(raw *ZipImage) error {
m, err := e.wz.CreateRaw(raw.Header)
if err != nil {
return err
@ -69,7 +69,7 @@ func (e *EpubZip) WriteRaw(raw *ZipImage) error {
}
// Write file. Compressed it using deflate.
func (e *EpubZip) WriteContent(file string, content []byte) error {
func (e *EPUBZip) WriteContent(file string, content []byte) error {
m, err := e.wz.CreateHeader(&zip.FileHeader{
Name: file,
Modified: time.Now(),

View File

@ -1,9 +1,9 @@
/*
Convert CBZ/CBR/Dir into Epub for e-reader devices (Kindle Devices, ...)
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, crossplatform, 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.
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.
*/
package main