Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image procesing in the CMYK colorspace #3789

Open
cagseylan opened this issue Sep 6, 2023 · 0 comments
Open

Image procesing in the CMYK colorspace #3789

cagseylan opened this issue Sep 6, 2023 · 0 comments
Labels

Comments

@cagseylan
Copy link

Dear All, I have two questions about existing(?) features. I have a number of 5 channel images. The first 4 channels correspond to C, M, Y, and K in CMYK colorspace, the last channel is the alpha (transparency) channel. According to the API documentation I can create such an image by joining channels with raw data, and then converting the output to cmyk, the last channel being interpreted as alpha. However, when I query the metadata of the resulting image, it seems there are only 4 channels. Here is the code piece of this try:

const cmykImg = sharp(cBuf, {
        raw: {
            width: h,
            height: w,
            channels: 1
        }
    }).joinChannel(mBuf, {raw: {height: h, width: w, channels: 1}})
        .joinChannel(yBuf, {raw: {height: h, width: w, channels: 1}})
        .joinChannel(kBuf, {raw: {height: h, width: w, channels: 1}})
        .joinChannel(aBuf, {raw: {height: h, width: w, channels: 1}})
        .toColorspace('cmyk')

const cmykBuf = await cmykImg.tiff().toBuffer()
const imgTif = sharp(buf)

metadata() for imgTif is as follows:

{
  format: 'tiff',
  size: 4613,
  space: 'cmyk',
  channels: 4,
  depth: 'uchar',
  isProgressive: false,
  pages: 1,
  resolutionUnit: 'inch',
  hasProfile: false,
  hasAlpha: false,
  orientation: 1
}

I tried with tiff because it supports both cmyk and transparency. Although the colorspace is cmyk, number of channels is 4 and hasAlpha is false. Does sharp support such images currently? If yes, what is the correct way of achieving this?

Furthermore, I need to do image composition with these 5 channel images. I can do this with png images in sharp easily. Is composition supported in the same way with cmyk-alpha images?

@cagseylan cagseylan changed the title Image procesing in CMYK colorspace Image procesing in the CMYK colorspace Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant