summaryrefslogtreecommitdiff
path: root/pdf.go
diff options
context:
space:
mode:
Diffstat (limited to 'pdf.go')
-rw-r--r--pdf.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/pdf.go b/pdf.go
index 2287ba9..6543e35 100644
--- a/pdf.go
+++ b/pdf.go
@@ -12,7 +12,7 @@ import (
"html"
"image"
"image/jpeg"
- "image/png"
+ _ "image/png"
"io/ioutil"
"os"
@@ -78,7 +78,7 @@ func (p *Fpdf) AddPage(imgpath, hocrpath string, smaller bool) error {
if err != nil {
return errors.New(fmt.Sprintf("Could not open file %s: %v", imgpath, err))
}
- img, imgtype, err := image.Decode(imgf)
+ img, _, err := image.Decode(imgf)
if err != nil {
return errors.New(fmt.Sprintf("Could not decode image: %v", err))
}
@@ -96,18 +96,14 @@ func (p *Fpdf) AddPage(imgpath, hocrpath string, smaller bool) error {
}
var buf bytes.Buffer
- if imgtype == "jpeg" {
- err = jpeg.Encode(&buf, img, &jpeg.Options{Quality: jpeg.DefaultQuality})
- } else {
- err = png.Encode(&buf, img)
- }
+ err = jpeg.Encode(&buf, img, &jpeg.Options{Quality: jpeg.DefaultQuality})
if err != nil {
return err
}
p.fpdf.AddPageFormat("P", gofpdf.SizeType{Wd: pxToPt(b.Dx()), Ht: pxToPt(b.Dy())})
- _ = p.fpdf.RegisterImageOptionsReader(imgpath, gofpdf.ImageOptions{ImageType: imgtype}, &buf)
+ _ = p.fpdf.RegisterImageOptionsReader(imgpath, gofpdf.ImageOptions{ImageType: "jpeg"}, &buf)
p.fpdf.ImageOptions(imgpath, 0, 0, pxToPt(b.Dx()), pxToPt(b.Dy()), false, gofpdf.ImageOptions{}, 0, "")
p.fpdf.SetTextRenderingMode(3)