我想将输入的JPEG图像转换为sRGB颜色配置文件。
这个cli变体效果很好:
gm convert src.jpg -profile sRGB.icc -strip dst.jpg
但这种变体不起作用:
FILE *f = fopen("./sRGB.icc", "rb");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
unsigned char *profile = malloc(fsize);
n = fread(string, 1, fsize, f);
fclose(f);
res = ProfileImage(image, "ICM", profile, fsize, MagickFalse); // also try "ICC"
// got MagickFail
我该怎么做?
答案 0 :(得分:0)
我用liblcms.a重建了最新的libgraphicsmagicks.a,一切都很顺利。
unsigned char sRGB_icc[] = {...}; // save sRGB.icc in source code
unsigned int sRGB_icc_len = ...;
ProfileImage(image, "ICM", sRGB_icc, sRGB_icc_len, MagickTrue); // "-profile"
ProfileImage(image, "*", NULL, 0, MagickFalse); // "-strip"