This commit is contained in:
Celogeek 2023-04-17 18:30:26 +02:00
parent a2eeda8479
commit ef27485273
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
4 changed files with 14 additions and 7 deletions

View File

@ -31,9 +31,10 @@ func (p *positionFilter) Draw(dst draw.Image, src image.Image, options *gift.Opt
draw.Draw(dst, dst.Bounds(), image.White, dst.Bounds().Min, draw.Over)
srcBounds := src.Bounds()
left, top := (p.viewWidth-srcBounds.Dx())/2, (p.viewHeight-srcBounds.Dy())/2
if p.align == PositionLeft {
left = 0
left, top := 0, (p.viewHeight-srcBounds.Dy())/2
if p.align == PositionCenter {
left = (p.viewWidth - srcBounds.Dx()) / 2
}
if p.align == PositionRight {

View File

@ -20,8 +20,8 @@ func NewGift(options *ImageOptions) *gift.GIFT {
}
g.Add(
filters.Resize(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
filters.Pixel(),
filters.Position(options.ViewWidth, options.ViewHeight, filters.PositionCenter),
filters.Pixel(),
)
return g
}

View File

@ -10,6 +10,7 @@ import (
func NewBar(max int, description string, currentJob, totalJob int) *progressbar.ProgressBar {
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(totalJob)))
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
return progressbar.DefaultBytesSilent(int64(max))
return progressbar.NewOptions(max,
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionOnCompletion(func() {

View File

@ -44,9 +44,14 @@ func (e *ePub) getToc(title string, images []*Image) string {
if len(ol.ChildElements()) == 1 && e.StripFirstDirectoryFromToc {
ol = ol.ChildElements()[0]
}
if len(ol.ChildElements()) > 0 {
nav.AddChild(ol)
}
beginning := etree.NewElement("li")
beginningLink := beginning.CreateElement("a")
beginningLink.CreateAttr("href", images[0].TextPath())
beginningLink.CreateText("Start of the book")
ol.InsertChildAt(0, beginning)
nav.AddChild(ol)
doc.Indent(2)
r, _ := doc.WriteToString()