webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.
https://docs.webp.sh
GNU General Public License v3.0
1.83k stars 175 forks source link

Can't encode source image: VipsJpeg: Invalid SOS parameters for sequential JPEG #208

Closed bhzhu203 closed 1 year ago

bhzhu203 commented 1 year ago

Original image http://static-erp.selleroa.com/yfni/test/1684547034231096980.jpg

WARN[2023-05-20 05:28:13][188:main.webpEncoder()] Can't encode source image: VipsJpeg: Invalid SOS parameters for sequential JPEG

Stack:
goroutine 3845 [running]:
runtime/debug.Stack()
    /root/go/src/runtime/debug/stack.go:24 +0x65
github.com/davidbyttow/govips/v2/vips.handleVipsError()
    /root/gopath/pkg/mod/github.com/davidbyttow/govips/v2@v2.13.0/vips/error.go:38 +0x57
github.com/davidbyttow/govips/v2/vips.handleSaveBufferError(0xc000d40a48?)
    /root/gopath/pkg/mod/github.com/davidbyttow/govips/v2@v2.13.0/vips/error.go:31 +0x25
github.com/davidbyttow/govips/v2/vips.vipsSaveToBuffer({0x7f9714013190, 0x0, 0x2, 0x0, 0x1, 0x55, 0x0, 0x0, 0x1, 0x0, ...})
    /root/gopath/pkg/mod/github.com/davidbyttow/govips/v2@v2.13.0/vips/foreign.go:465 +0xb7
github.com/davidbyttow/govips/v2/vips.vipsSaveWebPToBuffer(0x7f9714013190, {0x1, 0x55, 0x0, 0x0, 0x0, {0x0, 0x0}})
    /root/gopath/pkg/mod/github.com/davidbyttow/govips/v2@v2.13.0/vips/foreign.go:386 +0x1f8
github.com/davidbyttow/govips/v2/vips.(*ImageRef).ExportWebp(0xc006186050, 0x33?)
    /root/gopath/pkg/mod/github.com/davidbyttow/govips/v2@v2.13.0/vips/image.go:924 +0xc5
main.webpEncoder({0xc00f320140, 0x33}, {0xc000d8a500, 0x37}, 0x55, {0xb8ca58?, 0xc0003db860?})
    /root/webp_server_go/encoder.go:180 +0x17b
main.convertImage({0xc00f320140, 0x33}, {0xc000d8a500, 0x37}, {0xaec5ab, 0x4}, {0xc0003cf4a0?, 0xc000027180?})
    /root/webp_server_go/encoder.go:98 +0x2db
main.convertFilter.func2()
    /root/webp_server_go/encoder.go:55 +0x5c
created by main.convertFilter
    /root/webp_server_go/encoder.go:54 +0x215
 to WebP
n0vad3v commented 1 year ago

There are two problems here:

  1. The image might be corrupted. (Through it seems fine when opening through image viewer on my computer)
  2. When convert fails, the original image should be returned, this will be fixed by https://github.com/webp-sh/webp_server_go/pull/209
bhzhu203 commented 1 year ago

Hello , aliyun CDN webp service can convert the corrupted jpg image to webp correctly.

http://cdn3.selleroa.com/yfni/test/1684547034231096980.jpg

@n0vad3v