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

Use toDataURL() to output CMYK image, but get 'RangeError: unsupported number of channels: 5' #592

Open
YakumoAoi opened this issue Apr 27, 2022 · 1 comment

Comments

@YakumoAoi
Copy link

YakumoAoi commented Apr 27, 2022

l use a random image in my pc to convert to CMYK, And it works well
But when l use a image dataURL from svg exported by Adobe Illustrator
l get such error message

js code

let image = await IJS.Image.load(imageUrl)
if (image.colorModel === 'CMYK') return imageUrl
let CMYKImage = image.cmyk()
return CMYKImage.toDataURL()

@faizulhaque
Copy link

There are 6 export methods available

  save(path: string, options?: SaveOptions): Promise<void>;
  toDataURL(type?: string, options?: SaveOptions): string;
  toBase64(type?: string, options?: SaveOptions): string | Promise<string>;
  toBuffer(options?: SaveOptions): Uint8Array;
  toBlob(type?: string, quality?: number): Promise<Blob>;
  getCanvas(): HTMLCanvasElement;

After converting image to cmyk
e.g.
let CMYKImage = image.cmyk()

None of the above export methods work. It doesn't matter whatever the type provided.

e.g.

for type: image/jpeg:

Error:
Uncaught (in promise) TypeError: The process: getRGBAData can only be applied if the number of components is in: 1,3 at Image.checkProcessable (checkProcessable.js:54:1)

for type: image/png:

Error:
PngEncoder.ts:156 Uncaught (in promise) RangeError: unsupported number of channels: 5 at getColorType (PngEncoder.ts:156:1) at PngEncoder._checkData (PngEncoder.ts:109:1) at new PngEncoder (PngEncoder.ts:33:1) at encodePng (index.ts:22:1) at encodePng (export.js:40:1) at dataUrl (export.js:130:1) at Image.toDataURL (export.js:137:1) at Image.toBase64 (export.js:183:1)

Can any one suggest which export method with type works after .cmyk() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants