From 66d6c22e559851cb0e2183faf8af78a287c7a5cc Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Thu, 27 Apr 2023 15:58:40 +0200 Subject: [PATCH] improve cover title --- internal/epub/epub.go | 2 +- .../epub/imagefilters/epub_image_filters_cover_title.go | 8 ++++---- internal/epub/imageprocessing/epub_image_processing.go | 6 +++--- .../epub/imageprocessing/epub_image_processing_loader.go | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/epub/epub.go b/internal/epub/epub.go index eb915ff..16ff0c1 100644 --- a/internal/epub/epub.go +++ b/internal/epub/epub.go @@ -296,7 +296,7 @@ func (e *ePub) Write() error { return err } } - if err := wz.WriteImage(epubimageprocessing.LoadCoverTitleData(part.Cover, title, e.Image.Quality)); err != nil { + if err := wz.WriteImage(epubimageprocessing.CoverTitleData(part.Cover.Raw, title, e.Image.Quality)); err != nil { return err } diff --git a/internal/epub/imagefilters/epub_image_filters_cover_title.go b/internal/epub/imagefilters/epub_image_filters_cover_title.go index b6f0cf8..a42c507 100644 --- a/internal/epub/imagefilters/epub_image_filters_cover_title.go +++ b/internal/epub/imagefilters/epub_image_filters_cover_title.go @@ -57,16 +57,16 @@ func (p *coverTitle) Draw(dst draw.Image, src image.Image, options *gift.Options dst, borderArea, image.Black, - image.Point{}, - draw.Over, + borderArea.Min, + draw.Src, ) draw.Draw( dst, textArea, image.White, - image.Point{}, - draw.Over, + textArea.Min, + draw.Src, ) // Draw text diff --git a/internal/epub/imageprocessing/epub_image_processing.go b/internal/epub/imageprocessing/epub_image_processing.go index d7ebfdf..ab78178 100644 --- a/internal/epub/imageprocessing/epub_image_processing.go +++ b/internal/epub/imageprocessing/epub_image_processing.go @@ -116,11 +116,11 @@ func LoadImages(o *Options) ([]*epubimage.Image, error) { } // create a title page with the cover -func LoadCoverTitleData(img *epubimage.Image, title string, quality int) *epubimagedata.ImageData { +func CoverTitleData(img image.Image, title string, quality int) *epubimagedata.ImageData { // Create a blur version of the cover g := gift.New(epubimagefilters.CoverTitle(title)) - dst := image.NewGray(g.Bounds(img.Raw.Bounds())) - g.Draw(dst, img.Raw) + dst := image.NewGray(g.Bounds(img.Bounds())) + g.Draw(dst, img) return epubimagedata.NewRaw("OEBPS/Images/title.jpg", dst, quality) } diff --git a/internal/epub/imageprocessing/epub_image_processing_loader.go b/internal/epub/imageprocessing/epub_image_processing_loader.go index f3a27c2..b3139d9 100644 --- a/internal/epub/imageprocessing/epub_image_processing_loader.go +++ b/internal/epub/imageprocessing/epub_image_processing_loader.go @@ -51,6 +51,7 @@ func (o *Options) WorkersRatio(pct int) (nbWorkers int) { return } +// Load images from input func (o *Options) Load() (totalImages int, output chan *tasks, err error) { fi, err := os.Stat(o.Input) if err != nil {