mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
use img helper
This commit is contained in:
parent
06cc6d2788
commit
12cd279bb8
@ -87,7 +87,7 @@ func (e *ePub) writeImage(wz *epubzip.EpubZip, img *epubimageprocessing.LoadedIm
|
|||||||
// write blank page
|
// 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(
|
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{
|
[]byte(e.render(epubtemplates.Blank, map[string]any{
|
||||||
"Title": fmt.Sprintf("Blank Page %d", img.Id),
|
"Title": fmt.Sprintf("Blank Page %d", img.Id),
|
||||||
"ViewPort": fmt.Sprintf("width=%d,height=%d", e.Image.View.Width, e.Image.View.Height),
|
"ViewPort": fmt.Sprintf("width=%d,height=%d", e.Image.View.Width, e.Image.View.Height),
|
||||||
|
@ -85,28 +85,29 @@ func LoadImages(o *epuboptions.Options) (LoadedImages, error) {
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
for img := range imageInput {
|
for input := range imageInput {
|
||||||
src := img.Image
|
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
|
var raw image.Image
|
||||||
if img.Id == 0 && part == 0 {
|
if input.Id == 0 && part == 0 {
|
||||||
raw = dst
|
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{
|
imageOutput <- &LoadedImage{
|
||||||
Image: &epubimage.Image{
|
Image: img,
|
||||||
Id: img.Id,
|
ZipImage: epubzip.CompressImage(fmt.Sprintf("OEBPS/%s", img.ImgPath()), dst, o.Image.Quality),
|
||||||
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),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user