Compare commits

...

2 Commits

Author SHA1 Message Date
e5818146a8 v0.0.489
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m54s
2024-07-23 14:21:03 +02:00
1310054121 v0.0.488 fix wpdf with 16bpp images
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 4m9s
2024-07-22 15:16:28 +02:00
3 changed files with 13 additions and 5 deletions

View File

@@ -3,8 +3,8 @@ package cursortoken
import ( import (
"encoding/base32" "encoding/base32"
"encoding/json" "encoding/json"
"errors"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
"strings" "strings"
"time" "time"
) )
@@ -127,7 +127,7 @@ func Decode(tok string) (CursorToken, error) {
} }
if !strings.HasPrefix(tok, "tok_") { if !strings.HasPrefix(tok, "tok_") {
return CursorToken{}, errors.New("could not decode token, missing prefix") return CursorToken{}, exerr.New(exerr.TypeCursorTokenDecode, "could not decode token, missing prefix").Str("token", tok).Build()
} }
body, err := base32.StdEncoding.DecodeString(tok[len("tok_"):]) body, err := base32.StdEncoding.DecodeString(tok[len("tok_"):])
@@ -138,7 +138,7 @@ func Decode(tok string) (CursorToken, error) {
var tokenDeserialize cursorTokenSerialize var tokenDeserialize cursorTokenSerialize
err = json.Unmarshal(body, &tokenDeserialize) err = json.Unmarshal(body, &tokenDeserialize)
if err != nil { if err != nil {
return CursorToken{}, err return CursorToken{}, exerr.Wrap(err, "failed to deserialize token").Str("token", tok).Build()
} }
token := CursorToken{Mode: CTMNormal} token := CursorToken{Mode: CTMNormal}

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.487" const GoextVersion = "0.0.489"
const GoextVersionTimestamp = "2024-07-18T17:45:56+0200" const GoextVersionTimestamp = "2024-07-23T14:21:03+0200"

View File

@@ -7,6 +7,7 @@ import (
"gogs.mikescher.com/BlackForestBytes/goext/langext" "gogs.mikescher.com/BlackForestBytes/goext/langext"
"image" "image"
"image/color" "image/color"
"image/draw"
"net/http" "net/http"
) )
@@ -284,6 +285,13 @@ func (b *WPDFBuilder) Image(img *PDFImageRef, opts ...*PDFImageOpt) {
} }
} }
if dataimg.ColorModel() != color.RGBAModel && dataimg.ColorModel() != color.NRGBAModel {
// the image cannto be 16bpp or similar - otherwise fpdf errors out
dataImgRGBA := image.NewNRGBA(image.Rect(0, 0, dataimg.Bounds().Dx(), dataimg.Bounds().Dy()))
draw.Draw(dataImgRGBA, dataImgRGBA.Bounds(), dataimg, dataimg.Bounds().Min, draw.Src)
dataimg = dataImgRGBA
}
bfr, imgMime, err := imageext.EncodeImage(dataimg, compression) bfr, imgMime, err := imageext.EncodeImage(dataimg, compression)
if err != nil { if err != nil {
b.b.SetError(err) b.b.SetError(err)