Feature request
When constructing a Sharp instance from a raw pixel buffer, there is no way to declare the colorspace of those bytes. The raw input option only accepts { width, height, channels, depth? }. Four-channel raw input is always interpreted as RGBA, making it impossible to feed modified CMYK raw bytes back into Sharp for re-encoding as a CMYK JPEG.
What are you trying to achieve?
This blocks any workflow that needs to: decode a CMYK image → manipulate individual channel values in JS → re-encode as CMYK JPEG, without a lossy sRGB round-trip.
When you searched for similar feature requests, what did you find that might be related?
Issue #3620 fixed the pipelineColorspace CMYK roundtrip in v0.32.1, which is related but does not address raw input colorspace declaration.
Also saw #3789
What would you expect the API to look like?
sharp(rawCmykBuffer, {
raw: {
width: 400,
height: 300,
channels: 4,
colorspace: 'cmyk' // <-- missing option
}
})
.toColorspace('cmyk')
.jpeg({ quality: 95 })
.toBuffer()
Alternatively, a pipelineColorspace hint on the constructor that applies to raw input would achieve the same result.
What alternatives have you considered?
converting to RGB, but want to avoid conversion potential loss. Output image is embedded in .pdf for CMYK printing.
Please provide sample image(s) that help explain this feature
Any image.
Feature request
When constructing a Sharp instance from a raw pixel buffer, there is no way to declare the colorspace of those bytes. The
rawinput option only accepts{ width, height, channels, depth? }. Four-channel raw input is always interpreted as RGBA, making it impossible to feed modified CMYK raw bytes back into Sharp for re-encoding as a CMYK JPEG.What are you trying to achieve?
This blocks any workflow that needs to: decode a CMYK image → manipulate individual channel values in JS → re-encode as CMYK JPEG, without a lossy sRGB round-trip.
When you searched for similar feature requests, what did you find that might be related?
Issue #3620 fixed the
pipelineColorspaceCMYK roundtrip in v0.32.1, which is related but does not address raw input colorspace declaration.Also saw #3789
What would you expect the API to look like?
Alternatively, a
pipelineColorspacehint on the constructor that applies to raw input would achieve the same result.What alternatives have you considered?
converting to RGB, but want to avoid conversion potential loss. Output image is embedded in .pdf for CMYK printing.
Please provide sample image(s) that help explain this feature
Any image.