diff --git a/internal/epub/epub.go b/internal/epub/epub.go index dc849aa..c2b6c49 100644 --- a/internal/epub/epub.go +++ b/internal/epub/epub.go @@ -87,7 +87,7 @@ func (e *ePub) writeImage(wz *epubzip.EpubZip, img *epubimageprocessing.LoadedIm // write blank page func (e *ePub) writeBlank(wz *epubzip.EpubZip, img *epubimage.Image) error { return wz.WriteContent( - fmt.Sprintf("OEBPS/Text/%d_sp.xhtml", img.Id), + fmt.Sprintf("OEBPS/%s", img.SpacePath()), []byte(e.render(epubtemplates.Blank, map[string]any{ "Title": fmt.Sprintf("Blank Page %d", img.Id), "ViewPort": fmt.Sprintf("width=%d,height=%d", e.Image.View.Width, e.Image.View.Height), diff --git a/internal/epub/imageprocessing/epub_image_processing.go b/internal/epub/imageprocessing/epub_image_processing.go index f7fd975..3314e98 100644 --- a/internal/epub/imageprocessing/epub_image_processing.go +++ b/internal/epub/imageprocessing/epub_image_processing.go @@ -85,28 +85,29 @@ func LoadImages(o *epuboptions.Options) (LoadedImages, error) { go func() { defer wg.Done() - for img := range imageInput { - src := img.Image + for input := range imageInput { + src := input.Image - for part, dst := range TransformImage(src, img.Id, o.Image) { + for part, dst := range TransformImage(src, input.Id, o.Image) { var raw image.Image - if img.Id == 0 && part == 0 { + if input.Id == 0 && part == 0 { raw = dst } + img := &epubimage.Image{ + Id: input.Id, + Part: part, + Raw: raw, + Width: dst.Bounds().Dx(), + Height: dst.Bounds().Dy(), + IsCover: input.Id == 0 && part == 0, + DoublePage: part == 0 && src.Bounds().Dx() > src.Bounds().Dy(), + Path: input.Path, + Name: input.Name, + } imageOutput <- &LoadedImage{ - Image: &epubimage.Image{ - Id: img.Id, - Part: part, - Raw: raw, - Width: dst.Bounds().Dx(), - Height: dst.Bounds().Dy(), - IsCover: img.Id == 0 && part == 0, - DoublePage: part == 0 && src.Bounds().Dx() > src.Bounds().Dy(), - Path: img.Path, - Name: img.Name, - }, - ZipImage: epubzip.CompressImage(fmt.Sprintf("OEBPS/Images/%d_p%d.jpg", img.Id, part), dst, o.Image.Quality), + Image: img, + ZipImage: epubzip.CompressImage(fmt.Sprintf("OEBPS/%s", img.ImgPath()), dst, o.Image.Quality), } } }