Skip to content

Thumbnail generation fails: ipsJpeg: Invalid SOS parameters for sequential JPEG #1280

@heijligen

Description

@heijligen

Describe the bug

Some Images taken from Samsung phones with some firmware versions produces jpeg images with invalid SOS parameters for sequential JPEG.

Related to lovell/sharp#1578

Steps to reproduce

  1. Upload a "broken" image
  2. Try to preview

Expected behavior

A preview should be loaded

Actual behavior

The preview fails to load

Setup

Opencloud 3.2.0+nixos
thumbnail settings increased to be larger than image file size, width and height

I can provide a image file on request.


Error log of the event:
{"level":"warn","service":"thumbnails","method":"Thumbnails.GetThumbnail","duration":233.273078,"error":"VipsJpeg: Invalid SOS parameters for sequential JPEG\n\nStack:\ngoroutine 11077 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:26 +0x64\ngithub.com/davidbyttow/govips/v2/vips.handleVipsError()\n\tgithub.com/davidbyttow/govips/v2@v2.16.0/vips/error.go:38 +0x38\ngithub.com/davidbyttow/govips/v2/vips.handleSaveBufferError(0x4008e710a0?)\n\tgithub.com/davidbyttow/govips/v2@v2.16.0/vips/error.go:31 +0x24\ngithub.com/davidbyttow/govips/v2/vips.vipsSaveToBuffer({0xffff40050990, 0x0, 0x1, 0x0, 0x0, 0x50, 0x1, 0x0, 0x0, 0x0, ...})\n\tgithub.com/davidbyttow/govips/v2@v2.16.0/vips/foreign.go:505 +0xc8\ngithub.com/davidbyttow/govips/v2/vips.vipsSaveJPEGToBuffer(0xffff40050990, {0x0, 0x50, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0})\n\tgithub.com/davidbyttow/govips/v2@v2.16.0/vips/foreign.go:367 +0x124\ngithub.com/davidbyttow/govips/v2/vips.(*ImageRef).ExportJpeg(0x4000d4ed70, 0x30?)\n\tgithub.com/davidbyttow/govips/v2@v2.16.0/vips/image.go:940 +0x8c\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/thumbnail.JpegEncoder.Encode({}, {0x42207a0, 0x4000c2bb00}, {0x358d0e0?, 0x4000d4ed70?})\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/thumbnail/encoding_vips.go:50 +0x68\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/thumbnail.SimpleManager.Generate({{0x424b6c8, 0x4009e8b000}, {{{0x4235ee8, 0x400a259280}, 0x2, {0x0, 0x0}, {0x400a11ec00, 0x17, 0x1f4}, ...}}, ...}, ...)\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/thumbnail/thumbnail.go:72 +0x188\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0.Thumbnail.handleCS3Source({{0x400a22f920, 0x1b}, {0x3721ed5, 0x25}, {0x40012d1650, 0x20}, {0x4244980, 0x4008cfc0b0}, {0x42267e0, 0x400a237000}, ...}, ...)\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/service.go:176 +0x51c\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0.Thumbnail.GetThumbnail({{0x400a22f920, 0x1b}, {0x3721ed5, 0x25}, {0x40012d1650, 0x20}, {0x4244980, 0x4008cfc0b0}, {0x42267e0, 0x400a237000}, ...}, ...)\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/service.go:90 +0xbc\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/decorators.instrument.GetThumbnail({{{0x422ace0?, 0x4008cb70e0?}}, 0x4001172180?}, {0x424ab78, 0x400a70ae40}, 0x40046d75e0, 0x4001fd2600)\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/decorators/instrument.go:33 +0x114\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/decorators.logging.GetThumbnail({{{0x4226820, 0x4000381050}}, {{{0x4235ee8, 0x400a259280}, 0x2, {0x0, 0x0}, {0x400a11ec00, 0x17, 0x1f4}, ...}}}, ...)\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/decorators/logging.go:29 +0x98\ngithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/decorators.tracing.GetThumbnail({{{0x4226840?, 0x4009e8b080?}}, {0x4237af8?, 0x4009d61440?}}, {0x424ab78?, 0x400a70ae10?}, 0x40046d75e0?, 0x4001fd2600?)\n\tgithub.com/opencloud-eu/opencloud/services/thumbnails/pkg/service/grpc/v0/decorators/tracing.go:45 +0x3f0\ngithub.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/thumbnails/v0.(*thumbnailServiceHandler).GetThumbnail(0x2ba7100?, {0x424ab78?, 0x400a70ae10?}, 0x4bad90?, 0x319f620?)\n\tgithub.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/thumbnails/v0/thumbnails.pb.micro.go:90 +0x30\nreflect.Value.call({0x400a24f320?, 0x4009e96558?, 0x34003e0?}, {0x35beb18, 0x4}, {0x4001a6d1d8, 0x4, 0x162afec?})\n\treflect/value.go:584 +0x978\nreflect.Value.Call({0x400a24f320?, 0x4009e96558?, 0x400a70ae10?}, {0x4001a6d1d8?, 0x424abb0?, 0x2000040023ea8ad?})\n\treflect/value.go:368 +0x94\ngithub.com/go-micro/plugins/v4/server/grpc.(*grpcServer).processRequest.func1({0x424ab78?, 0x400a70ae10?}, {0x4237af8?, 0x4009d61440?}, {0x32db220, 0x4001fd2600})\n\tgithub.com/go-micro/plugins/v4/server/grpc@v1.2.0/grpc.go:406 +0x204\ngithub.com/go-micro/plugins/v4/wrapper/trace/opentelemetry.NewHandlerWrapper.func1.1({0x424abb0, 0x400a8299a0}, {0x4264880, 0x4007025f00}, {0x32db220, 0x4001fd2600})\n\tgithub.com/go-micro/plugins/v4/wrapper/trace/opentelemetry@v1.2.0/wrapper.go:58 +0x1e0\ngithub.com/go-micro/plugins/v4/wrapper/monitoring/prometheus.(*wrapper).HandlerFunc-fm.(*wrapper).HandlerFunc.func1({0x424abb0, 0x400a8299a0}, {0x4264880, 0x4007025f00}, {0x32db220, 0x4001fd2600})\n\tgithub.com/go-micro/plugins/v4/wrapper/monitoring/prometheus@v1.2.0/prometheus.go:250 +0x110\ngithub.com/go-micro/plugins/v4/server/grpc.(*grpcServer).processRequest(0x400a248340, {0x42576b0, 0x4008e70e00}, 0x400a251740, 0x4009d61710, {0x400ad4e1f8, 0x16}, {0x424abb0, 0x400a8299a0})\n\tgithub.com/go-micro/plugins/v4/server/grpc@v1.2.0/grpc.go:423 +0x464\ngithub.com/go-micro/plugins/v4/server/grpc.(*grpcServer).handler(0x400a248340, {0x940f84?, 0x30?}, {0x42576b0, 0x4008e70e00})\n\tgithub.com/go-micro/plugins/v4/server/grpc@v1.2.0/grpc.go:345 +0x760\ngoogle.golang.org/grpc.(*Server).processStreamingRPC(0x400a91f200, {0x424ab78, 0x400a70a990}, 0x4001fd25a0, 0x0, 0x40011724c0, 0x0)\n\tgoogle.golang.org/grpc@v1.74.0/server.go:1721 +0xebc\ngoogle.golang.org/grpc.(*Server).handleStream(0x400a91f200, {0x424bce8, 0x400997eb60}, 0x4001fd25a0)\n\tgoogle.golang.org/grpc@v1.74.0/server.go:1851 +0x8a8\ngoogle.golang.org/grpc.(*Server).serveStreams.func2.1()\n\tgoogle.golang.org/grpc@v1.74.0/server.go:1061 +0x84\ncreated by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 11169\n\tgoogle.golang.org/grpc@v1.74.0/server.go:1072 +0x138\n","time":"2025-07-27T14:47:49+02:00","message":"Failed to execute"}

Additional context

With opencloud-eu/web#456 this issue has a reduced effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Qualification

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions