Conversion of RGB to CMYK image using Icc profiles #190
Answered
by
necessarylion
necessarylion
asked this question in
Q&A
-
Hi, I have a magick command that convert rgb image to cmyk with icc profiles. magick test.webp -profile input/sRGB.icc -profile output/CoatedFOGRA39.icc -colorspace cmyk test_out.jpg And I am looking for similar code in javascript. Currently, this is what I have so far but the output color is not exactly what I got from upper command. (eg. light green become dark green) const data = await urlToUint8Array('test.webp')
const rgb = await urlToUint8Array('input/sRGB.icc')
const cmyk = await urlToUint8Array('output/CoatedFOGRA39.icc')
ImageMagick.read(data, (image) => {
image.setProfile('rgb', rgb)
image.colorSpace = ColorSpace.CMYK
image.setProfile('CoatedFOGRA39', cmyk)
image.write(MagickFormat.Jpg, async (imageData: Uint8Array) => {
// code to download image
});
})
async function urlToUint8Array(url: string) {
const response = await fetch(url);
if (!response.ok) throw new Error('failed to fetch')
const arrayBuffer = await response.arrayBuffer();
return new Uint8Array(arrayBuffer);
} |
Beta Was this translation helpful? Give feedback.
Answered by
necessarylion
Dec 3, 2024
Replies: 1 comment 8 replies
-
There is not yet a public api available for this but it I can add support for this in the next release. Might take a couple days before I have time to work on this and I can probably publish a new release after that. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @dlemstra, It work perfectly with:
But, if I create color profile with the name
new new ColorProfile('rgb', rgb)
, it throw below error