png-save: avoid storing CMYK ICC profiles

In that case we've stored synthetic sRGB profile based data, discard
profile when saving to satisfy libpng sanity.
parent a460be25
......@@ -160,6 +160,8 @@ export_png (GeglOperation *operation,
double green[2];
double blue[2];
const Babl *trc[3];
int is_cmyk = babl_space_is_cmyk (space);
babl_space_get (space, &wp[0], &wp[1],
&red[0], &red[1],
&green[0], &green[1],
......@@ -168,7 +170,7 @@ export_png (GeglOperation *operation,
png_set_cHRM (png, info, wp[0], wp[1], red[0], red[1], green[0], green[1], blue[0], blue[1]);
/* XXX: should also set gamma based on trc! */
if (trc[0] == babl_trc("sRGB") ||
trc[0] == babl_trc("2.2"))
trc[0] == babl_trc("2.2") || is_cmyk)
{
png_set_gAMA (png, info, 2.2);
}
......@@ -181,7 +183,7 @@ export_png (GeglOperation *operation,
png_set_gAMA (png, info, 2.2);
}
{
if (!is_cmyk) {
int icc_len;
const char *name = babl_get_name (space);
const char *icc_profile;
......
......@@ -24,6 +24,12 @@
property_file_path (path, _("File"), "")
description (_("Target path and filename, use '-' for stdout"))
property_int (bitdepth, _("Bitdepth"), -1)
description (_("-1, 8, 16, 32 and 64 are the currently accepted values, -1 means auto"))
value_range (-1, 64)
property_int (ieeef, _("IEEEF"), -1)
description (_("floating point -1 means auto, 0 means integer 1 meant float."))
value_range (-1, 1)
#else
......@@ -549,12 +555,38 @@ export_tiff (GeglOperation *operation,
else
{
g_warning("sample format not supported: %s", babl_get_name(type));
sample_format = SAMPLEFORMAT_UINT;
type = babl_type("u8");
bits_per_sample = 8;
}
if (o->bitdepth > 0)
{
switch (o->bitdepth)
{
case 8:
bits_per_sample = 8;
break;
case 16:
bits_per_sample = 16;
break;
case 32:
bits_per_sample = 32;
break;
case 64:
bits_per_sample = 64;
break;
}
}
if (o->ieeef >= 0)
{
if (o->ieeef == 1)
sample_format = SAMPLEFORMAT_IEEEFP;
else
sample_format = SAMPLEFORMAT_UINT;
}
TIFFSetField(p->tiff, TIFFTAG_BITSPERSAMPLE, bits_per_sample);
TIFFSetField(p->tiff, TIFFTAG_SAMPLEFORMAT, sample_format);
......@@ -569,8 +601,23 @@ export_tiff (GeglOperation *operation,
return -1;
}
if (o->bitdepth > 0 || o->ieeef >= 0)
{
switch (bits_per_sample)
{
case 8: type = babl_type ("u8");
sample_format = SAMPLEFORMAT_UINT;
break;
case 16: type = babl_type (o->ieeef==1?"half":"u16"); break;
case 32: type = babl_type (o->ieeef==1?"float":"u32"); break;
case 64: type = babl_type ("double");
sample_format = SAMPLEFORMAT_IEEEFP;
break;
}
}
g_snprintf(format_string, 32, "%s %s",
babl_get_name(model), babl_get_name(type));
babl_get_name(model), babl_get_name(type));
format = babl_format_with_space (format_string, space);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment