Skip to content

Bun.Image: CMYK JPEG decode fails with "Image: decode failed" #31895

Closed

Description

@gabooh

What version of Bun is running?

1.3.14 (Linux x64, glibc)

What steps will reproduce the bug?

Create a baseline CMYK JPEG and transform it with Bun.Image:

magick -size 64x64 xc:cyan -colorspace CMYK cmyk.jpg   # any 4-component (CMYK/YCCK) JPEG
const bytes = await Bun.file("cmyk.jpg").bytes();
await new Bun.Image(bytes).resize(32, 32).jpeg().bytes();

What is the expected behavior?

The CMYK JPEG is decoded and re-encoded to sRGB, like libvips/sharp and ImageMagick do (they auto-convert CMYK→sRGB on output).

What do you see instead?

The pipeline throws Image: decode failed.

Notably, await new Bun.Image(bytes).metadata() succeeds and returns { width, height, format: "jpeg" } — the header parses fine, but pixel decoding of 4-component (CMYK / YCCK) JPEGs fails.

Additional information

CMYK JPEGs are common in print-oriented / publishing image libraries. sharp (libvips) and ImageMagick both decode them and convert to sRGB. This currently forces a fallback to sharp for the affected images.

Activity

  1. robobun commented on Jun 5, 2026

    @robobun
    Collaborator

    ✅ Reproduced on 1.4.0: metadata() parses the header but pixel decode of 4-component (CMYK/YCCK) JPEGs throws Image: decode failed.

    Fix → #31898, ready for a maintainer to merge. The image tests pass on every CI lane that ran them; the remaining red lanes are unrelated failures that also occur on main.

  2. added a commit that references this issue on Aug 24, 2026
    3b15054
  3. added a commit that references this issue on Sep 5, 2026
    57097ba
  4. added a commit that references this issue on Sep 5, 2026
    7b0b70e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions