Commit 1425e4f3 authored by Tobias Ellinghaus's avatar Tobias Ellinghaus

Don't use export's conf to pass data to colorout

Abusing the configuration system by setting override profile/intent in
the export namespace from all over the code to control what colorout
does is bad style and prone to race conditions. It also messes with
exporting images.

Fixes #11787
parent aafdb649
......@@ -357,13 +357,20 @@ int main(int argc, char *arg[])
storage->set_params(storage, sdata, storage->params_size(storage));
}
// TODO: do we want to use the settings from conf?
// TODO: expose these via command line arguments
dt_colorspaces_color_profile_type_t icc_type = DT_COLORSPACE_NONE;
const gchar *icc_filename = NULL;
dt_iop_color_intent_t icc_intent = DT_INTENT_LAST;
// TODO: add a callback to set the bpp without going through the config
int num = 1;
for(GList *iter = id_list; iter; iter = g_list_next(iter), num++)
{
int id = GPOINTER_TO_INT(iter->data);
storage->store(storage, sdata, id, format, fdata, num, total, high_quality, upscale);
storage->store(storage, sdata, id, format, fdata, num, total, high_quality, upscale, icc_type, icc_filename,
icc_intent);
}
// cleanup time
......
......@@ -526,15 +526,18 @@ void dt_imageio_to_fractional(float in, uint32_t *num, uint32_t *den)
int dt_imageio_export(const uint32_t imgid, const char *filename, dt_imageio_module_format_t *format,
dt_imageio_module_data_t *format_params, const gboolean high_quality, const gboolean upscale,
const gboolean copy_metadata, dt_imageio_module_storage_t *storage,
dt_imageio_module_data_t *storage_params, int num, int total)
const gboolean copy_metadata, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent,
dt_imageio_module_storage_t *storage, dt_imageio_module_data_t *storage_params, int num,
int total)
{
if(strcmp(format->mime(format_params), "x-copy") == 0)
/* This is a just a copy, skip process and just export */
return format->write_image(format_params, filename, NULL, NULL, 0, imgid, num, total);
else
return dt_imageio_export_with_flags(imgid, filename, format, format_params, 0, 0, high_quality, upscale,
0, NULL, copy_metadata, storage, storage_params, num, total);
0, NULL, copy_metadata, icc_type, icc_filename, icc_intent, storage,
storage_params, num, total);
}
// internal function: to avoid exif blob reading + 8-bit byteorder flag + high-quality override
......@@ -543,6 +546,8 @@ int dt_imageio_export_with_flags(const uint32_t imgid, const char *filename,
const int32_t ignore_exif, const int32_t display_byteorder,
const gboolean high_quality, const gboolean upscale, const int32_t thumbnail_export,
const char *filter, const gboolean copy_metadata,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
dt_iop_color_intent_t icc_intent,
dt_imageio_module_storage_t *storage,
dt_imageio_module_data_t *storage_params, int num, int total)
{
......@@ -672,6 +677,7 @@ int dt_imageio_export_with_flags(const uint32_t imgid, const char *filename,
g_list_free_full(style_items, dt_style_item_free);
}
dt_dev_pixelpipe_set_icc(&pipe, icc_type, icc_filename, icc_intent);
dt_dev_pixelpipe_set_input(&pipe, &dev, (float *)buf.buf, buf.width, buf.height, buf.iscale);
dt_dev_pixelpipe_create_nodes(&pipe, &dev);
dt_dev_pixelpipe_synch_all(&pipe, &dev);
......@@ -689,12 +695,11 @@ int dt_imageio_export_with_flags(const uint32_t imgid, const char *filename,
// find output color profile for this image:
int sRGB = 1;
int icctype = dt_conf_get_int("plugins/lighttable/export/icctype");
if(icctype == DT_COLORSPACE_SRGB)
if(icc_type == DT_COLORSPACE_SRGB)
{
sRGB = 1;
}
else if(icctype == DT_COLORSPACE_NONE)
else if(icc_type == DT_COLORSPACE_NONE)
{
GList *modules = dev.iop;
dt_iop_module_t *colorout = NULL;
......
......@@ -67,15 +67,17 @@ struct dt_imageio_module_format_t;
struct dt_imageio_module_data_t;
int dt_imageio_export(const uint32_t imgid, const char *filename, struct dt_imageio_module_format_t *format,
struct dt_imageio_module_data_t *format_params, const gboolean high_quality, const gboolean upscale,
const gboolean copy_metadata, dt_imageio_module_storage_t *storage,
const gboolean copy_metadata, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent, dt_imageio_module_storage_t *storage,
dt_imageio_module_data_t *storage_params, int num, int total);
int dt_imageio_export_with_flags(const uint32_t imgid, const char *filename,
struct dt_imageio_module_format_t *format,
struct dt_imageio_module_data_t *format_params, const int32_t ignore_exif,
const int32_t display_byteorder, const gboolean high_quality, const gboolean upscale,
const int32_t thumbnail_export, const char *filter,
const gboolean copy_metadata, dt_imageio_module_storage_t *storage,
const int32_t thumbnail_export, const char *filter, const gboolean copy_metadata,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
dt_iop_color_intent_t icc_intent, dt_imageio_module_storage_t *storage,
dt_imageio_module_data_t *storage_params, int num, int total);
size_t dt_imageio_write_pos(int i, int j, int wd, int ht, float fwd, float fht,
......
......@@ -18,7 +18,8 @@
#pragma once
#include <common/darktable.h>
#include "common/colorspaces.h"
#include "common/darktable.h"
#include <gmodule.h>
#include <gtk/gtk.h>
#include <inttypes.h>
......@@ -172,7 +173,9 @@ typedef struct dt_imageio_module_storage_t
/* this actually does the work */
int (*store)(struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *self_data,
const int imgid, dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata,
const int num, const int total, const gboolean high_quality, const gboolean upscale);
const int num, const int total, const gboolean high_quality, const gboolean upscale,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
dt_iop_color_intent_t icc_intent);
/* called once at the end (after exporting all images), if implemented. */
void (*finalize_store)(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data);
......
......@@ -1218,7 +1218,7 @@ static void _init_8(uint8_t *buf, uint32_t *width, uint32_t *height, float *isca
// export with flags: ignore exif (don't load from disk), don't swap byte order, don't do hq processing,
// no upscaling and signal we want thumbnail export
res = dt_imageio_export_with_flags(imgid, "unused", &format, (dt_imageio_module_data_t *)&dat, 1, 0, 0, 0, 1,
NULL, FALSE, NULL, NULL, 1, 1);
NULL, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL, NULL, 1, 1);
if(!res)
{
// might be smaller, or have a different aspect than what we got as input.
......
......@@ -65,6 +65,9 @@ typedef struct dt_control_export_t
gboolean high_quality, upscale;
char style[128];
gboolean style_append;
dt_colorspaces_color_profile_type_t icc_type;
gchar *icc_filename;
dt_iop_color_intent_t icc_intent;
} dt_control_export_t;
typedef struct dt_control_image_enumerator_t
......@@ -443,7 +446,7 @@ static int32_t dt_control_merge_hdr_job_run(dt_job_t *job)
const uint32_t imgid = GPOINTER_TO_INT(t->data);
dt_imageio_export_with_flags(imgid, "unused", &buf, (dt_imageio_module_data_t *)&dat, 1, 0, 0, 1, 0,
"pre:rawprepare", 0, 0, 0, num, total);
"pre:rawprepare", 0, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL, NULL, num, total);
t = g_list_delete_link(t, t);
......@@ -1256,7 +1259,8 @@ static int32_t dt_control_export_job_run(dt_job_t *job)
else
{
dt_image_cache_read_release(darktable.image_cache, image);
if(mstorage->store(mstorage, sdata, imgid, mformat, fdata, num, total, settings->high_quality, settings->upscale) != 0)
if(mstorage->store(mstorage, sdata, imgid, mformat, fdata, num, total, settings->high_quality,
settings->upscale, settings->icc_type, settings->icc_filename, settings->icc_intent) != 0)
dt_control_job_cancel(job);
}
}
......@@ -1597,13 +1601,16 @@ static void dt_control_export_cleanup(void *p)
mstorage->free_params(mstorage, sdata);
g_free(settings->icc_filename);
free(params->data);
dt_control_image_enumerator_cleanup(params);
}
void dt_control_export(GList *imgid_list, int max_width, int max_height, int format_index, int storage_index,
gboolean high_quality, gboolean upscale, char *style, gboolean style_append)
gboolean high_quality, gboolean upscale, char *style, gboolean style_append,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
dt_iop_color_intent_t icc_intent)
{
dt_job_t *job = dt_control_job_create(&dt_control_export_job_run, "export");
if(!job) return;
......@@ -1638,6 +1645,9 @@ void dt_control_export(GList *imgid_list, int max_width, int max_height, int for
data->upscale = upscale;
g_strlcpy(data->style, style, sizeof(data->style));
data->style_append = style_append;
data->icc_type = icc_type;
data->icc_filename = g_strdup(icc_filename);
data->icc_intent = icc_intent;
dt_control_job_add_progress(job, _("export images"), TRUE);
dt_control_add_job(darktable.control, DT_JOB_QUEUE_USER_EXPORT, job);
......
......@@ -40,7 +40,9 @@ void dt_control_copy_images();
void dt_control_set_local_copy_images();
void dt_control_reset_local_copy_images();
void dt_control_export(GList *imgid_list, int max_width, int max_height, int format_index, int storage_index,
gboolean high_quality, gboolean upscale, char *style, gboolean style_append);
gboolean high_quality, gboolean upscale, char *style, gboolean style_append,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
dt_iop_color_intent_t icc_intent);
void dt_control_merge_hdr();
void dt_control_seed_denoise();
......
......@@ -149,6 +149,10 @@ int dt_dev_pixelpipe_init_cached(dt_dev_pixelpipe_t *pipe, size_t size, int32_t
pipe->levels = IMAGEIO_RGB | IMAGEIO_INT8;
dt_pthread_mutex_init(&(pipe->backbuf_mutex), NULL);
dt_pthread_mutex_init(&(pipe->busy_mutex), NULL);
pipe->icc_type = DT_COLORSPACE_NONE;
pipe->icc_filename = NULL;
pipe->icc_intent = DT_INTENT_LAST;
return 1;
}
......@@ -163,6 +167,15 @@ void dt_dev_pixelpipe_set_input(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, flo
get_output_format(NULL, pipe, NULL, dev, &pipe->dsc);
}
void dt_dev_pixelpipe_set_icc(dt_dev_pixelpipe_t *pipe, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
pipe->icc_type = icc_type;
g_free(pipe->icc_filename);
pipe->icc_filename = g_strdup(icc_filename);
pipe->icc_intent = icc_intent;
}
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe)
{
dt_pthread_mutex_lock(&pipe->backbuf_mutex);
......@@ -174,6 +187,9 @@ void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe)
dt_pthread_mutex_unlock(&pipe->backbuf_mutex);
dt_pthread_mutex_destroy(&(pipe->backbuf_mutex));
dt_pthread_mutex_destroy(&(pipe->busy_mutex));
pipe->icc_type = DT_COLORSPACE_NONE;
g_free(pipe->icc_filename);
pipe->icc_filename = NULL;
}
void dt_dev_pixelpipe_cleanup_nodes(dt_dev_pixelpipe_t *pipe)
......
......@@ -126,6 +126,10 @@ typedef struct dt_dev_pixelpipe_t
int devid;
// image struct as it was when the pixelpipe was initialized. copied to avoid race conditions.
dt_image_t image;
// the user might choose to overwrite the output color space and rendering intent.
dt_colorspaces_color_profile_type_t icc_type;
gchar *icc_filename;
dt_iop_color_intent_t icc_intent;
} dt_dev_pixelpipe_t;
struct dt_develop_t;
......@@ -147,6 +151,9 @@ int dt_dev_pixelpipe_init_cached(dt_dev_pixelpipe_t *pipe, size_t size, int32_t
// constructs a new input buffer from given RGB float array.
void dt_dev_pixelpipe_set_input(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, float *input, int width,
int height, float iscale);
// set some metadata for colorout to avoid race conditions.
void dt_dev_pixelpipe_set_icc(dt_dev_pixelpipe_t *pipe, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent);
// returns the dimensions of the full image after processing.
void dt_dev_pixelpipe_get_dimensions(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int width_in,
......
......@@ -195,7 +195,8 @@ void gui_reset(dt_imageio_module_storage_t *self)
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
dt_imageio_disk_t *d = (dt_imageio_disk_t *)sdata;
......@@ -302,7 +303,8 @@ try_again:
if(fail) return 1;
/* export image to file */
if(dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, TRUE, self, sdata, num, total) != 0)
if(dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, TRUE, icc_type, icc_filename,
icc_intent, self, sdata, num, total) != 0)
{
fprintf(stderr, "[imageio_storage_disk] could not export to file: `%s'!\n", filename);
dt_control_log(_("could not export to file `%s'!"), filename);
......
......@@ -97,7 +97,8 @@ void gui_reset(dt_imageio_module_storage_t *self)
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
dt_imageio_email_t *d = (dt_imageio_email_t *)sdata;
......@@ -127,7 +128,8 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
attachment->file = g_build_filename(tmpdir, dirname, (char *)NULL);
if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality, upscale, FALSE, self, sdata, num, total) != 0)
if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename,
icc_intent, self, sdata, num, total) != 0)
{
fprintf(stderr, "[imageio_storage_email] could not export to file: `%s'!\n", attachment->file);
dt_control_log(_("could not export to file `%s'!"), attachment->file);
......
......@@ -1246,7 +1246,8 @@ int supported(struct dt_imageio_module_storage_t *self, struct dt_imageio_module
/* this actually does the work */
int store(dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
gint result = 1;
dt_storage_facebook_param_t *p = (dt_storage_facebook_param_t *)sdata;
......@@ -1291,7 +1292,8 @@ int store(dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *sd
if(fdata->max_height == 0 || fdata->max_height > FB_IMAGE_MAX_SIZE) fdata->max_height = FB_IMAGE_MAX_SIZE;
if(fdata->max_width == 0 || fdata->max_width > FB_IMAGE_MAX_SIZE) fdata->max_width = FB_IMAGE_MAX_SIZE;
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale, FALSE, self, sdata, num, total)
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename, icc_intent,
self, sdata, num, total)
!= 0)
{
g_printerr("[facebook] could not export to file: `%s'!\n", fname);
......
......@@ -111,6 +111,7 @@ static void _flickr_api_free(_flickr_api_context_t *ctx)
static void _flickr_api_error_handler(void *data, const char *message)
{
dt_control_log(_("flickr authentication: %s"), message);
fprintf(stderr, "[flickr] error: %s\n", message);
if(data)
{
_flickr_api_context_t *ctx = (_flickr_api_context_t *)data;
......@@ -589,7 +590,8 @@ void gui_reset(dt_imageio_module_storage_t *self)
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
gint result = 0;
dt_storage_flickr_params_t *p = (dt_storage_flickr_params_t *)sdata;
......@@ -640,7 +642,8 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
}
dt_image_cache_read_release(darktable.image_cache, img);
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale, FALSE, self, sdata, num, total) != 0)
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename, icc_intent,
self, sdata, num, total) != 0)
{
fprintf(stderr, "[imageio_storage_flickr] could not export to file: `%s'!\n", fname);
dt_control_log(_("could not export to file `%s'!"), fname);
......
......@@ -213,7 +213,8 @@ static gint sort_pos(pair_t *a, pair_t *b)
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
dt_imageio_gallery_t *d = (dt_imageio_gallery_t *)sdata;
......@@ -326,7 +327,8 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
// export image to file. need this to be able to access meaningful
// fdata->width and height below.
if(dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, self, sdata, num, total) != 0)
if(dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename,
icc_intent, self, sdata, num, total) != 0)
{
fprintf(stderr, "[imageio_storage_gallery] could not export to file: `%s'!\n", filename);
dt_control_log(_("could not export to file `%s'!"), filename);
......@@ -360,7 +362,8 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
if(c <= filename || *c == '/') c = filename + strlen(filename);
ext = format->extension(fdata);
sprintf(c, "-thumb.%s", ext);
if(dt_imageio_export(imgid, filename, format, fdata, FALSE, TRUE, FALSE, self, sdata, num, total) != 0)
if(dt_imageio_export(imgid, filename, format, fdata, FALSE, TRUE, FALSE, icc_type, icc_filename, icc_intent, self,
sdata, num, total) != 0)
{
fprintf(stderr, "[imageio_storage_gallery] could not export to file: `%s'!\n", filename);
dt_control_log(_("could not export to file `%s'!"), filename);
......
......@@ -29,6 +29,8 @@ extern "C" {
struct dt_imageio_module_storage_t;
struct dt_imageio_module_format_t;
struct dt_imageio_module_data_t;
enum dt_colorspaces_color_profile_type_t;
enum dt_iop_color_intent_t;
/* early definition of modules to do type checking */
......@@ -65,7 +67,9 @@ int initialize_store(struct dt_imageio_module_storage_t *self, struct dt_imageio
/* this actually does the work */
int store(struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *self_data,
const int imgid, struct dt_imageio_module_format_t *format, struct dt_imageio_module_data_t *fdata,
const int num, const int total, const gboolean high_quality, const gboolean upscale);
const int num, const int total, const gboolean high_quality, const gboolean upscale,
enum dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
enum dt_iop_color_intent_t icc_intent);
/* called once at the end (after exporting all images), if implemented. */
void finalize_store(struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *data);
......
......@@ -216,7 +216,8 @@ static gint sort_pos(pair_t *a, pair_t *b)
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale,dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
dt_imageio_latex_t *d = (dt_imageio_latex_t *)sdata;
......@@ -347,7 +348,8 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
dt_pthread_mutex_unlock(&darktable.plugin_threadsafe);
/* export image to file */
dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, self, sdata, num, total);
dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename, icc_intent,
self, sdata, num, total);
printf("[export_job] exported to `%s'\n", filename);
char *trunc = filename + strlen(filename) - 32;
......
......@@ -1248,7 +1248,8 @@ int supported(struct dt_imageio_module_storage_t *self, struct dt_imageio_module
/* this actually does the work */
int store(dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *sdata, const int imgid,
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
const gboolean high_quality, const gboolean upscale)
const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
gint result = 1;
PicasaContext *ctx = (PicasaContext *)sdata;
......@@ -1281,7 +1282,8 @@ int store(dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *sd
dt_image_cache_read_release(darktable.image_cache, img);
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale, FALSE, self, sdata, num, total) != 0)
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename, icc_intent,
self, sdata, num, total) != 0)
{
g_printerr("[picasa] could not export to file: `%s'!\n", fname);
dt_control_log(_("could not export to file `%s'!"), fname);
......
......@@ -498,9 +498,6 @@ void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pix
dt_iop_colorout_data_t *d = (dt_iop_colorout_data_t *)piece->data;
d->type = p->type;
const dt_colorspaces_color_profile_type_t over_type = dt_conf_get_int("plugins/lighttable/export/icctype");
gchar *over_filename = dt_conf_get_string("plugins/lighttable/export/iccprofile");
const dt_iop_color_intent_t over_intent = dt_conf_get_int("plugins/lighttable/export/iccintent");
const int force_lcms2 = dt_conf_get_bool("plugins/lighttable/export/force_lcms2");
......@@ -530,12 +527,12 @@ void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pix
/* if we are exporting then check and set usage of override profile */
if(pipe->type == DT_DEV_PIXELPIPE_EXPORT)
{
if(over_type != DT_COLORSPACE_NONE)
if(pipe->icc_type != DT_COLORSPACE_NONE)
{
p->type = over_type;
g_strlcpy(p->filename, over_filename, sizeof(p->filename));
p->type = pipe->icc_type;
g_strlcpy(p->filename, pipe->icc_filename, sizeof(p->filename));
}
if((unsigned int)over_intent < DT_INTENT_LAST) p->intent = over_intent;
if((unsigned int)pipe->icc_intent < DT_INTENT_LAST) p->intent = pipe->icc_intent;
out_type = p->type;
out_filename = p->filename;
......@@ -559,7 +556,7 @@ void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pix
// and the subsequent error messages
d->type = out_type;
if(out_type == DT_COLORSPACE_LAB)
goto end;
return;
/*
* Setup transform flags
......@@ -678,8 +675,6 @@ void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pix
// softproof is never the original but always a copy that went through _make_clipping_profile()
dt_colorspaces_cleanup_profile(softproof);
end:
g_free(over_filename);
}
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
......
......@@ -112,6 +112,9 @@ static void export_button_clicked(GtkWidget *widget, gpointer user_data)
g_strlcpy(style, tmp, sizeof(style));
g_free(tmp);
}
dt_colorspaces_color_profile_type_t icc_type = dt_conf_get_int("plugins/lighttable/export/icctype");
gchar *icc_filename = dt_conf_get_string("plugins/lighttable/export/iccprofile");
dt_iop_color_intent_t icc_intent = dt_conf_get_int("plugins/lighttable/export/iccintent");
int imgid = dt_view_get_image_to_act_on();
GList *list = NULL;
......@@ -122,7 +125,9 @@ static void export_button_clicked(GtkWidget *widget, gpointer user_data)
list = dt_collection_get_selected(darktable.collection, -1);
dt_control_export(list, max_width, max_height, format_index, storage_index, high_quality, upscale,
style, style_append);
style, style_append, icc_type, icc_filename, icc_intent);
g_free(icc_filename);
}
static void width_changed(GtkSpinButton *spin, gpointer user_data)
......
......@@ -245,11 +245,14 @@ _print_button_clicked (GtkWidget *widget, gpointer user_data)
g_free(style);
}
// the flags are: ignore exif, display byteorder, high quality, upscale, thumbnail
const int high_quality = 1;
const int upscale = 1;
dt_imageio_export_with_flags(imgid, "unused", &buf, (dt_imageio_module_data_t *)&dat, 1, 0,
high_quality, upscale, 0, NULL, FALSE, 0, 0, 1, 1);
dt_colorspaces_color_profile_type_t icc_type = dt_conf_get_int("plugins/print/print/icctype");
gchar *icc_filename = dt_conf_get_string("plugins/print/print/iccprofile");
dt_iop_color_intent_t icc_intent = dt_conf_get_int("plugins/print/print/iccintent");
dt_imageio_export_with_flags(imgid, "unused", &buf, (dt_imageio_module_data_t *)&dat, 1, 0, high_quality, upscale, 0,
NULL, FALSE, icc_type, icc_filename, icc_intent, NULL, NULL, 1, 1);
g_free(icc_filename);
// after exporting we know the real size of the image, compute the layout
......@@ -755,9 +758,7 @@ _profile_changed(GtkWidget *widget, dt_lib_module_t *self)
dt_lib_export_profile_t *pp = (dt_lib_export_profile_t *)prof->data;
if(pp->pos == pos)
{
dt_conf_set_int("plugins/lighttable/export/icctype", pp->type);
dt_conf_set_int("plugins/print/print/icctype", pp->type);
dt_conf_set_string("plugins/lighttable/export/iccprofile", pp->filename);
dt_conf_set_string("plugins/print/print/iccprofile", pp->filename);
g_free(ps->v_iccprofile);
ps->v_icctype = pp->type;
......@@ -766,9 +767,7 @@ _profile_changed(GtkWidget *widget, dt_lib_module_t *self)
}
prof = g_list_next(prof);
}
dt_conf_set_int("plugins/lighttable/export/icctype", DT_COLORSPACE_NONE);
dt_conf_set_int("plugins/print/print/icctype", DT_COLORSPACE_NONE);
dt_conf_set_string("plugins/lighttable/export/iccprofile", "");
dt_conf_set_string("plugins/print/print/iccprofile", "");
g_free(ps->v_iccprofile);
ps->v_icctype = DT_COLORSPACE_NONE;
......@@ -831,7 +830,6 @@ _intent_callback (GtkWidget *widget, dt_lib_module_t *self)
dt_lib_print_settings_t *ps = (dt_lib_print_settings_t *)self->data;
const int pos = dt_bauhaus_combobox_get(widget);
// record the intent that will override the out rendering module on export
dt_conf_set_int("plugins/lighttable/export/iccintent", pos - 1);
dt_conf_set_int("plugins/print/print/iccintent", pos - 1);
ps->v_intent = pos - 1;
}
......
......@@ -158,7 +158,9 @@ static int write_image(lua_State *L)
dt_lua_unlock();
gboolean high_quality = dt_conf_get_bool("plugins/lighttable/export/high_quality_processing");
gboolean result = dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, NULL, NULL, 1, 1);
// TODO: expose icc overwrites to the user!
gboolean result = dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, DT_COLORSPACE_NONE,
NULL, DT_INTENT_LAST, NULL, NULL, 1, 1);
dt_lua_lock();
lua_pushboolean(L, result);
format->free_params(format, fdata);
......
......@@ -77,7 +77,9 @@ static int default_dimension_wrapper(struct dt_imageio_module_storage_t *self, d
static int store_wrapper(struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *self_data,
const int imgid, dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata,
const int num, const int total, const gboolean high_quality, const gboolean upscale)
const int num, const int total, const gboolean high_quality, const gboolean upscale,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
dt_iop_color_intent_t icc_intent)
{
/* construct a temporary file name */
......@@ -94,7 +96,8 @@ static int store_wrapper(struct dt_imageio_module_storage_t *self, struct dt_ima
gchar *complete_name = g_build_filename(tmpdir, filename, (char *)NULL);
if(dt_imageio_export(imgid, complete_name, format, fdata, high_quality, upscale, FALSE, self, self_data, num, total) != 0)
if(dt_imageio_export(imgid, complete_name, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename,
icc_intent, self, self_data, num, total) != 0)
{
fprintf(stderr, "[%s] could not export to file: `%s'!\n", self->name(self), complete_name);
g_free(complete_name);
......
......@@ -868,12 +868,17 @@ static gboolean export_key_accel_callback(GtkAccelGroup *accel_group, GObject *a
const gboolean upscale = dt_conf_get_bool("plugins/lighttable/export/upscale");
char *style = dt_conf_get_string("plugins/lighttable/export/style");
const gboolean style_append = dt_conf_get_bool("plugins/lighttable/export/style_append");
dt_colorspaces_color_profile_type_t icc_type = dt_conf_get_int("plugins/lighttable/export/icctype");
gchar *icc_filename = dt_conf_get_string("plugins/lighttable/export/iccprofile");
dt_iop_color_intent_t icc_intent = dt_conf_get_int("plugins/lighttable/export/iccintent");
// darkroom is for single images, so only export the one the user is working on
GList *l = g_list_append(NULL, GINT_TO_POINTER(dev->image_storage.id));
dt_control_export(l, max_width, max_height, format_index, storage_index, high_quality, upscale, style, style_append);
dt_control_export(l, max_width, max_height, format_index, storage_index, high_quality, upscale, style, style_append,
icc_type, icc_filename, icc_intent);
g_free(format_name);
g_free(storage_name);
g_free(style);
g_free(icc_filename);
return TRUE;
}
......
......@@ -66,9 +66,6 @@ typedef struct dt_slideshow_t
uint32_t back_width, back_height;
int32_t front_num, back_num;
// output profile before we overwrote it:
int old_profile_type;
// state machine stuff for image transitions:
dt_pthread_mutex_t lock;
dt_slideshow_state_t state; // global state cycle
......@@ -190,7 +187,7 @@ static int process_next_image(dt_slideshow_t *d)
if(id)
// the flags are: ignore exif, display byteorder, high quality, upscale, thumbnail
dt_imageio_export_with_flags(id, "unused", &buf, (dt_imageio_module_data_t *)&dat, 1, 1, high_quality, 1, 0,
0, 0, 0, 0, 1, 1);
0, 0, DT_COLORSPACE_DISPLAY, NULL, DT_INTENT_LAST, NULL, NULL, 1, 1);
return 0;
}
......@@ -351,10 +348,6 @@ void enter(dt_view_t *self)
// also hide arrows
dt_ui_border_show(darktable.gui->ui, FALSE);
// use display profile:
d->old_profile_type = dt_conf_get_int("plugins/lighttable/export/icctype");
dt_conf_set_int("plugins/lighttable/export/icctype", DT_COLORSPACE_DISPLAY);
// alloc screen-size double buffer
GtkWidget *window = dt_ui_main_window(darktable.gui->ui);
GdkRectangle rect;
......@@ -405,7 +398,6 @@ void leave(dt_view_t *self)
dt_ui_border_show(darktable.gui->ui, TRUE);
d->auto_advance = 0;
dt_view_lighttable_set_position(darktable.view_manager, d->front_num);
dt_conf_set_int("plugins/lighttable/export/icctype", d->old_profile_type);
dt_pthread_mutex_lock(&d->lock);
dt_free_align(d->buf1);
dt_free_align(d->buf2);
......
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