Skip to content

Commit

Permalink
fix(webp): better handling of error for page too big for webp
Browse files Browse the repository at this point in the history
  • Loading branch information
Belphemur committed Aug 28, 2024
1 parent 839ad9e commit a63d239
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions converter/webp/webp_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"sync/atomic"
)

const webpMaxHeight = 16383

type Converter struct {
maxHeight int
cropHeight int
Expand Down Expand Up @@ -202,6 +204,9 @@ func (converter *Converter) checkPageNeedsSplit(page *manga.Page) (bool, image.I
bounds := img.Bounds()
height := bounds.Dy()

if height >= converter.maxHeight {
return false, img, format, fmt.Errorf("page[%d] height %d exceeds maximum height %d of webp format", page.Index, height, converter.maxHeight)
}
return height >= converter.maxHeight, img, format, nil
}

Expand Down

0 comments on commit a63d239

Please sign in to comment.