Skip to content

Commit c7b97b8

Browse files
committed
fix scaling being read during running export job
During a running export job the image scaling factor is read from the GUI/settings for each exported image, resulting in different export sizes if the scaling factor is changed.
1 parent d0455fa commit c7b97b8

File tree

17 files changed

+87
-42
lines changed

17 files changed

+87
-42
lines changed

src/cli/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2012-2023 darktable developers.
3+
Copyright (C) 2012-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -778,7 +778,8 @@ int main(int argc, char *arg[])
778778
dt_export_metadata_t metadata;
779779
metadata.flags = dt_lib_export_metadata_default_flags();
780780
metadata.list = NULL;
781-
if(storage->store(storage, sdata, id, format, fdata, num, total, high_quality, upscale, export_masks,
781+
if(storage->store(storage, sdata, id, format, fdata, num, total, high_quality,
782+
upscale, FALSE, 1.0, export_masks,
782783
icc_type, icc_filename, icc_intent, &metadata) != 0)
783784
res = 1;
784785
}

src/common/gimp.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2024 darktable developers.
3+
Copyright (C) 2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -54,13 +54,15 @@ gboolean dt_export_gimp_file(const dt_imgid_t imgid)
5454
fdata->style_append = FALSE;
5555

5656
storage->store(storage, sdata, imgid, format, fdata, 1, 1,
57-
thumb ? FALSE : TRUE, // high_quality,
58-
FALSE, // never upscale
59-
thumb ? FALSE : TRUE, // export_masks
60-
thumb ? DT_COLORSPACE_SRGB : DT_COLORSPACE_LIN_REC709,
61-
NULL, // icc_filename
62-
DT_INTENT_PERCEPTUAL,
63-
NULL); // &metadata
57+
thumb ? FALSE : TRUE, // high_quality,
58+
FALSE, // never upscale
59+
FALSE,
60+
1.0,
61+
thumb ? FALSE : TRUE, // export_masks
62+
thumb ? DT_COLORSPACE_SRGB : DT_COLORSPACE_LIN_REC709,
63+
NULL, // icc_filename
64+
DT_INTENT_PERCEPTUAL,
65+
NULL); // &metadata
6466
printf("<<<gimp\n%s%s\n", path, thumb ? ".jpg" : ".exr");
6567
if(thumb)
6668
{

src/common/mipmap_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ static void _init_8(uint8_t *buf,
15671567
// swap byte order, don't do hq processing, no upscaling and
15681568
// signal we want thumbnail export
15691569
res = dt_imageio_export_with_flags(imgid, "unused", &format, (dt_imageio_module_data_t *)&dat, TRUE, FALSE, FALSE,
1570-
FALSE, FALSE, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
1570+
FALSE, FALSE, 1.0, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
15711571
NULL, 1, 1, NULL, -1);
15721572
if(!res)
15731573
{

src/control/jobs/control_jobs.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static int32_t _control_merge_hdr_job_run(dt_job_t *job)
631631

632632
const dt_imgid_t imgid = GPOINTER_TO_INT(t->data);
633633
dt_imageio_export_with_flags(imgid, "unused", &buf, (dt_imageio_module_data_t *)&dat,
634-
TRUE, FALSE, TRUE, TRUE, FALSE,
634+
TRUE, FALSE, TRUE, TRUE, FALSE, 1.0,
635635
FALSE, "pre:rawprepare", FALSE,
636636
FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
637637
NULL, num, total, NULL, -1);
@@ -1864,6 +1864,14 @@ static int32_t _control_export_job_run(dt_job_t *job)
18641864
"\x1b%G"); // ESC % G
18651865
}
18661866

1867+
// scaling
1868+
const gboolean is_scaling =
1869+
dt_conf_is_equal("plugins/lighttable/export/resizing", "scaling");
1870+
1871+
double _num, _denum;
1872+
dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
1873+
const double scale_factor = is_scaling? _num / _denum : 1.0;
1874+
18671875
dt_export_metadata_t metadata;
18681876
metadata.flags = 0;
18691877
metadata.list = dt_util_str_to_glist("\1", settings->metadata_export);
@@ -1907,6 +1915,7 @@ static int32_t _control_export_job_run(dt_job_t *job)
19071915
dt_image_cache_read_release(image);
19081916
if(mstorage->store(mstorage, sdata, imgid, mformat, fdata,
19091917
num, total, settings->high_quality, settings->upscale,
1918+
is_scaling, scale_factor,
19101919
settings->export_masks, settings->icc_type,
19111920
settings->icc_filename, settings->icc_intent,
19121921
&metadata) != 0)

src/imageio/imageio.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
977977
dt_imageio_module_data_t *format_params,
978978
const gboolean high_quality,
979979
const gboolean upscale,
980+
const gboolean is_scaling,
981+
const double scale_factor,
980982
const gboolean copy_metadata,
981983
const gboolean export_masks,
982984
const dt_colorspaces_color_profile_type_t icc_type,
@@ -995,12 +997,9 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
995997
export_masks)) != 0;
996998
else
997999
{
998-
const gboolean is_scaling =
999-
dt_conf_is_equal("plugins/lighttable/export/resizing", "scaling");
1000-
10011000
return dt_imageio_export_with_flags(imgid, filename, format, format_params,
10021001
FALSE, FALSE, high_quality, upscale,
1003-
is_scaling, FALSE, NULL, copy_metadata,
1002+
is_scaling, scale_factor, FALSE, NULL, copy_metadata,
10041003
export_masks, icc_type, icc_filename,
10051004
icc_intent, storage, storage_params,
10061005
num, total, metadata, -1);
@@ -1035,6 +1034,7 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,
10351034
const gboolean high_quality,
10361035
const gboolean upscale,
10371036
const gboolean is_scaling,
1037+
const double scale_factor,
10381038
const gboolean thumbnail_export,
10391039
const char *filter,
10401040
const gboolean copy_metadata,
@@ -1269,9 +1269,9 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,
12691269
if(is_scaling)
12701270
{
12711271
// scaling
1272-
double _num, _denum;
1273-
dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
1274-
const double scale_factor = _num / _denum;
1272+
// double _num, _denum;
1273+
// dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
1274+
// const double scale_factor = _num / _denum;
12751275
if(!thumbnail_export)
12761276
{
12771277
scale = fmin(scale_factor, max_scale);
@@ -1735,10 +1735,11 @@ cairo_surface_t *dt_imageio_preview(const dt_imgid_t imgid,
17351735
const gboolean upscale = TRUE;
17361736
const gboolean export_masks = FALSE;
17371737
const gboolean is_scaling = FALSE;
1738+
const double scale_factor = 1.0;
17381739

17391740
dt_imageio_export_with_flags
17401741
(imgid, "preview", &buf, (dt_imageio_module_data_t *)&dat, TRUE, TRUE,
1741-
high_quality, upscale, is_scaling, FALSE, NULL, FALSE, export_masks,
1742+
high_quality, upscale, is_scaling, scale_factor, FALSE, NULL, FALSE, export_masks,
17421743
DT_COLORSPACE_DISPLAY, NULL, DT_INTENT_LAST, NULL, NULL, 1, 1, NULL,
17431744
history_end);
17441745

src/imageio/imageio_common.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2009-2024 darktable developers.
3+
Copyright (C) 2009-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -91,6 +91,8 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
9191
struct dt_imageio_module_data_t *format_params,
9292
const gboolean high_quality,
9393
const gboolean upscale,
94+
const gboolean is_scaling,
95+
const double scale_factor,
9496
const gboolean copy_metadata,
9597
const gboolean export_masks,
9698
dt_colorspaces_color_profile_type_t icc_type,
@@ -110,6 +112,7 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid, const char *filena
110112
const gboolean high_quality,
111113
const gboolean upscale,
112114
const gboolean is_scaling,
115+
const double scale_factor,
113116
const gboolean thumbnail_export,
114117
const char *filter,
115118
const gboolean copy_metadata,

src/imageio/imageio_module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2010-2021 darktable developers.
3+
Copyright (C) 2010-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by

src/imageio/storage/disk.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2010-2024 darktable developers.
3+
Copyright (C) 2010-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -323,6 +323,8 @@ int store(dt_imageio_module_storage_t *self,
323323
const int total,
324324
const gboolean high_quality,
325325
const gboolean upscale,
326+
const gboolean is_scaling,
327+
const double scale_factor,
326328
const gboolean export_masks,
327329
dt_colorspaces_color_profile_type_t icc_type,
328330
const gchar *icc_filename,
@@ -486,7 +488,8 @@ int store(dt_imageio_module_storage_t *self,
486488

487489
/* export image to file */
488490
if(dt_imageio_export(imgid, filename, format, fdata, high_quality,
489-
upscale, TRUE, export_masks, icc_type,
491+
upscale, is_scaling, scale_factor,
492+
TRUE, export_masks, icc_type,
490493
icc_filename, icc_intent, self, sdata,
491494
num, total, metadata) != 0)
492495
{

src/imageio/storage/email.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2010-2023 darktable developers.
3+
Copyright (C) 2010-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -141,6 +141,8 @@ int store(dt_imageio_module_storage_t *self,
141141
const int total,
142142
const gboolean high_quality,
143143
const gboolean upscale,
144+
const gboolean is_scaling,
145+
const double scale_factor,
144146
const gboolean export_masks,
145147
dt_colorspaces_color_profile_type_t icc_type,
146148
const gchar *icc_filename,
@@ -176,7 +178,8 @@ int store(dt_imageio_module_storage_t *self,
176178
attachment->file = g_build_filename(tmpdir, dirname, (char *)NULL);
177179

178180
if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality,
179-
upscale, TRUE, export_masks, icc_type,
181+
upscale, is_scaling, scale_factor,
182+
TRUE, export_masks, icc_type,
180183
icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
181184
{
182185
dt_print(DT_DEBUG_ALWAYS,

src/imageio/storage/gallery.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2011-2024 darktable developers.
3+
Copyright (C) 2011-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -255,6 +255,8 @@ int store(dt_imageio_module_storage_t *self,
255255
const int total,
256256
const gboolean high_quality,
257257
const gboolean upscale,
258+
const gboolean is_scaling,
259+
const double scale_factor,
258260
const gboolean export_masks,
259261
dt_colorspaces_color_profile_type_t icc_type,
260262
const gchar *icc_filename,
@@ -395,7 +397,8 @@ int store(dt_imageio_module_storage_t *self,
395397
// export image to file. need this to be able to access meaningful
396398
// fdata->width and height below.
397399
if(dt_imageio_export(imgid, filename, format, fdata, high_quality,
398-
upscale, TRUE, export_masks, icc_type,
400+
upscale, is_scaling, scale_factor,
401+
TRUE, export_masks, icc_type,
399402
icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
400403
{
401404
dt_print(DT_DEBUG_ALWAYS,
@@ -436,6 +439,7 @@ int store(dt_imageio_module_storage_t *self,
436439
ext = format->extension(fdata);
437440
sprintf(c, "-thumb.%s", ext);
438441
if(dt_imageio_export(imgid, filename, format, fdata, FALSE, TRUE, FALSE,
442+
is_scaling, scale_factor,
439443
export_masks, icc_type, icc_filename,
440444
icc_intent, self, sdata, num, total, NULL) != 0)
441445
{

src/imageio/storage/imageio_storage_api.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2016-2023 darktable developers.
3+
Copyright (C) 2016-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU Lesser General Public License as published by
@@ -67,7 +67,9 @@ OPTIONAL(int, initialize_store, struct dt_imageio_module_storage_t *self, struct
6767
/* this actually does the work */
6868
REQUIRED(int, store, struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *self_data, const dt_imgid_t imgid,
6969
struct dt_imageio_module_format_t *format, struct dt_imageio_module_data_t *fdata, const int num,
70-
const int total, const gboolean high_quality, const gboolean upscale, const gboolean export_masks,
70+
const int total, const gboolean high_quality, const gboolean upscale,
71+
const gboolean is_scaling, const double scale_factor,
72+
const gboolean export_masks,
7173
const enum dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
7274
enum dt_iop_color_intent_t icc_intent, struct dt_export_metadata_t *metadata);
7375
/* called once at the end (after exporting all images), if implemented. */

src/imageio/storage/latex.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2012-2024 darktable developers.
3+
Copyright (C) 2012-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -224,7 +224,8 @@ static gint sort_pos(pair_t *a, pair_t *b)
224224

225225
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const dt_imgid_t imgid,
226226
dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
227-
const gboolean high_quality, const gboolean upscale, const gboolean export_masks,
227+
const gboolean high_quality, const gboolean upscale, const gboolean is_scaling,
228+
const double scale_factor, const gboolean export_masks,
228229
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent,
229230
dt_export_metadata_t *metadata)
230231
{
@@ -362,6 +363,7 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co
362363

363364
/* export image to file */
364365
dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale,
366+
is_scaling, scale_factor,
365367
TRUE, export_masks, icc_type, icc_filename,
366368
icc_intent, self, sdata, num, total, metadata);
367369

src/imageio/storage/piwigo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2018-2024 darktable developers.
3+
Copyright (C) 2018-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -1271,6 +1271,8 @@ int store(dt_imageio_module_storage_t *self,
12711271
const int total,
12721272
const gboolean high_quality,
12731273
const gboolean upscale,
1274+
const gboolean is_scaling,
1275+
const double scale_factor,
12741276
const gboolean export_masks,
12751277
const dt_colorspaces_color_profile_type_t icc_type,
12761278
const gchar *icc_filename,
@@ -1353,8 +1355,8 @@ int store(dt_imageio_module_storage_t *self,
13531355
g_free(filename);
13541356

13551357
dt_image_cache_read_release(img);
1356-
13571358
if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale,
1359+
is_scaling, scale_factor,
13581360
TRUE, export_masks, icc_type, icc_filename,
13591361
icc_intent, self, sdata, num, total, metadata) != 0)
13601362
{

src/libs/print_settings.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,11 @@ static int _export_image(dt_job_t *job, dt_image_box *img)
372372
const gboolean upscale = TRUE;
373373
const gboolean export_masks = FALSE;
374374
const gboolean is_scaling = FALSE;
375+
const double scale_factor = 1.0;
375376

376377
dt_imageio_export_with_flags
377378
(img->imgid, "unused", &buf, (dt_imageio_module_data_t *)&dat, TRUE, FALSE,
378-
high_quality, upscale, is_scaling, FALSE, NULL,
379+
high_quality, upscale, is_scaling, scale_factor, FALSE, NULL,
379380
FALSE, export_masks, params->buf_icc_type,
380381
params->buf_icc_profile, params->buf_icc_intent, NULL, NULL, 1, 1, NULL, -1);
381382

src/lua/format.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of darktable,
3-
Copyright (C) 2014-2023 darktable developers.
3+
Copyright (C) 2014-2025 darktable developers.
44
55
darktable is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -164,7 +164,17 @@ static int write_image(lua_State *L)
164164
// TODO: expose icc overwrites to the user!
165165
dt_colorspaces_color_profile_type_t icc_type = dt_conf_get_int("plugins/lighttable/export/icctype");
166166
const char *icc_filename = dt_conf_get_string_const("plugins/lighttable/export/iccprofile");
167-
gboolean result = dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, export_masks,
167+
168+
// scaling
169+
const gboolean is_scaling =
170+
dt_conf_is_equal("plugins/lighttable/export/resizing", "scaling");
171+
172+
double _num, _denum;
173+
dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
174+
const double scale_factor = is_scaling? _num / _denum : 1.0;
175+
176+
gboolean result = dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, is_scaling, scale_factor,
177+
FALSE, export_masks,
168178
icc_type, icc_filename, DT_INTENT_LAST, NULL, NULL, 1, 1, NULL);
169179
dt_lua_lock();
170180
// mitigate 17938 by returning sane values (true for success, false for failure)

0 commit comments

Comments
 (0)