Skip to content

Issue when applying an icc profile when colourspace is scRGB #4674

@jaume-pinyol

Description

@jaume-pinyol

Hi,
I have a weird issue that has started with version 8.17.x regarding colouspaces and icc profiles.

I have this sample image
Image
That has an embedded profile Adobe RGB (1998), the thing is that if I convert this file into colorspace scRGB and then import a profile then the result is a black image. This was working fine in versions <= 8.16.x

Image

I've made a test case to show you what I mean:

use-vips-func.c

#include <stdio.h>
#include <vips/vips.h>

int
main(int argc, char **argv)
{
	VipsImage *in;
	double mean;
	VipsImage *out;
	VipsImage *out2;

	if (VIPS_INIT(argv[0]))
		vips_error_exit(NULL);

	vips_cache_set_max_mem(0);
	vips_cache_set_max(0);

	vips_concurrency_set(1);

	if (argc != 3)
		vips_error_exit("usage: %s infile outfile", argv[0]);

	in = vips_image_new_from_file(argv[1], NULL);
	if (vips_avg(in, &mean, NULL))
		vips_error_exit(NULL);


	/* generate photo nexative - replace with other vips_ funcs */
	if (vips_colourspace(in, &out, VIPS_INTERPRETATION_scRGB, NULL))
		vips_error_exit(NULL);

	g_clear_object(&in);
	size_t length;
	const void *data;
	if (vips_image_get_blob(out, VIPS_META_ICC_NAME, &data, &length))
		vips_error_exit(NULL);

	if (vips_icc_is_compatible_profile(out, data, length)) {
		printf("Compatible profile\n");
	} else {
		printf("Not compatible profile\n");
	}

	if (vips_icc_import(out, &out2, "input_profile", "sRGB_v4_ICC_preference.icc", "embedded", TRUE, NULL))
		vips_error_exit(NULL);

	g_clear_object(&out);

	if (vips_image_write_to_file(out2, argv[2], NULL))
		vips_error_exit(NULL);

	g_clear_object(&out2);

	return 0;
}

If I convert it to some other colourspace then is fine.
Do you know if it's normal or did I just stumbled on a bug?
Thank you very much for the help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions