Skip to content

How to generate image from stream of raw input? #1579

@flipactual

Description

@flipactual

I am trying to create an image (ideally to be output as a png) from raw pixel data, but I'm struggling to understand the desired format

const rs = Readable();
  const transformer = sharp({
    raw: {
      width,
      height,
      channels: 3,
    },
  });
  rs.pipe(transformer).pipe(createWriteStream(outputPath));

I have tried setting _read on rs to push Uint8Arrays, Buffers, and other types representing RGB data, but I inevitably get the Error: Unexpected data on Writable Stream error

I'm stumped, any help would be greatly appreciated

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions