Skip to content

fix scaling being read during running export job #18943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cli/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2012-2023 darktable developers.
Copyright (C) 2012-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -778,7 +778,8 @@ int main(int argc, char *arg[])
dt_export_metadata_t metadata;
metadata.flags = dt_lib_export_metadata_default_flags();
metadata.list = NULL;
if(storage->store(storage, sdata, id, format, fdata, num, total, high_quality, upscale, export_masks,
if(storage->store(storage, sdata, id, format, fdata, num, total, high_quality,
upscale, FALSE, 1.0, export_masks,
icc_type, icc_filename, icc_intent, &metadata) != 0)
res = 1;
}
Expand Down
18 changes: 10 additions & 8 deletions src/common/gimp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2024 darktable developers.
Copyright (C) 2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -54,13 +54,15 @@ gboolean dt_export_gimp_file(const dt_imgid_t imgid)
fdata->style_append = FALSE;

storage->store(storage, sdata, imgid, format, fdata, 1, 1,
thumb ? FALSE : TRUE, // high_quality,
FALSE, // never upscale
thumb ? FALSE : TRUE, // export_masks
thumb ? DT_COLORSPACE_SRGB : DT_COLORSPACE_LIN_REC709,
NULL, // icc_filename
DT_INTENT_PERCEPTUAL,
NULL); // &metadata
thumb ? FALSE : TRUE, // high_quality,
FALSE, // never upscale
FALSE,
1.0,
thumb ? FALSE : TRUE, // export_masks
thumb ? DT_COLORSPACE_SRGB : DT_COLORSPACE_LIN_REC709,
NULL, // icc_filename
DT_INTENT_PERCEPTUAL,
NULL); // &metadata
printf("<<<gimp\n%s%s\n", path, thumb ? ".jpg" : ".exr");
if(thumb)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/mipmap_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ static void _init_8(uint8_t *buf,
// 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, TRUE, FALSE, FALSE,
FALSE, FALSE, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
FALSE, FALSE, 1.0, TRUE, NULL, FALSE, FALSE, DT_COLORSPACE_NONE, NULL, DT_INTENT_LAST, NULL,
NULL, 1, 1, NULL, -1);
if(!res)
{
Expand Down
11 changes: 10 additions & 1 deletion src/control/jobs/control_jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ static int32_t _control_merge_hdr_job_run(dt_job_t *job)

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

// scaling
const gboolean is_scaling =
dt_conf_is_equal("plugins/lighttable/export/resizing", "scaling");

double _num, _denum;
dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
const double scale_factor = is_scaling? _num / _denum : 1.0;

dt_export_metadata_t metadata;
metadata.flags = 0;
metadata.list = dt_util_str_to_glist("\1", settings->metadata_export);
Expand Down Expand Up @@ -1907,6 +1915,7 @@ static int32_t _control_export_job_run(dt_job_t *job)
dt_image_cache_read_release(image);
if(mstorage->store(mstorage, sdata, imgid, mformat, fdata,
num, total, settings->high_quality, settings->upscale,
is_scaling, scale_factor,
settings->export_masks, settings->icc_type,
settings->icc_filename, settings->icc_intent,
&metadata) != 0)
Expand Down
15 changes: 6 additions & 9 deletions src/imageio/imageio.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
dt_imageio_module_data_t *format_params,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean copy_metadata,
const gboolean export_masks,
const dt_colorspaces_color_profile_type_t icc_type,
Expand All @@ -995,12 +997,9 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
export_masks)) != 0;
else
{
const gboolean is_scaling =
dt_conf_is_equal("plugins/lighttable/export/resizing", "scaling");

return dt_imageio_export_with_flags(imgid, filename, format, format_params,
FALSE, FALSE, high_quality, upscale,
is_scaling, FALSE, NULL, copy_metadata,
is_scaling, scale_factor, FALSE, NULL, copy_metadata,
export_masks, icc_type, icc_filename,
icc_intent, storage, storage_params,
num, total, metadata, -1);
Expand Down Expand Up @@ -1035,6 +1034,7 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean thumbnail_export,
const char *filter,
const gboolean copy_metadata,
Expand Down Expand Up @@ -1268,10 +1268,6 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid,

if(is_scaling)
{
// scaling
double _num, _denum;
dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
const double scale_factor = _num / _denum;
if(!thumbnail_export)
{
scale = fmin(scale_factor, max_scale);
Expand Down Expand Up @@ -1735,10 +1731,11 @@ cairo_surface_t *dt_imageio_preview(const dt_imgid_t imgid,
const gboolean upscale = TRUE;
const gboolean export_masks = FALSE;
const gboolean is_scaling = FALSE;
const double scale_factor = 1.0;

dt_imageio_export_with_flags
(imgid, "preview", &buf, (dt_imageio_module_data_t *)&dat, TRUE, TRUE,
high_quality, upscale, is_scaling, FALSE, NULL, FALSE, export_masks,
high_quality, upscale, is_scaling, scale_factor, FALSE, NULL, FALSE, export_masks,
DT_COLORSPACE_DISPLAY, NULL, DT_INTENT_LAST, NULL, NULL, 1, 1, NULL,
history_end);

Expand Down
5 changes: 4 additions & 1 deletion src/imageio/imageio_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2009-2024 darktable developers.
Copyright (C) 2009-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -91,6 +91,8 @@ gboolean dt_imageio_export(const dt_imgid_t imgid,
struct dt_imageio_module_data_t *format_params,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean copy_metadata,
const gboolean export_masks,
dt_colorspaces_color_profile_type_t icc_type,
Expand All @@ -110,6 +112,7 @@ gboolean dt_imageio_export_with_flags(const dt_imgid_t imgid, const char *filena
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean thumbnail_export,
const char *filter,
const gboolean copy_metadata,
Expand Down
2 changes: 1 addition & 1 deletion src/imageio/imageio_module.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2010-2021 darktable developers.
Copyright (C) 2010-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
7 changes: 5 additions & 2 deletions src/imageio/storage/disk.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2010-2024 darktable developers.
Copyright (C) 2010-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -323,6 +323,8 @@ int store(dt_imageio_module_storage_t *self,
const int total,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean export_masks,
dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename,
Expand Down Expand Up @@ -486,7 +488,8 @@ int store(dt_imageio_module_storage_t *self,

/* export image to file */
if(dt_imageio_export(imgid, filename, format, fdata, high_quality,
upscale, TRUE, export_masks, icc_type,
upscale, is_scaling, scale_factor,
TRUE, export_masks, icc_type,
icc_filename, icc_intent, self, sdata,
num, total, metadata) != 0)
{
Expand Down
7 changes: 5 additions & 2 deletions src/imageio/storage/email.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2010-2023 darktable developers.
Copyright (C) 2010-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -141,6 +141,8 @@ int store(dt_imageio_module_storage_t *self,
const int total,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean export_masks,
dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename,
Expand Down Expand Up @@ -176,7 +178,8 @@ int store(dt_imageio_module_storage_t *self,
attachment->file = g_build_filename(tmpdir, dirname, (char *)NULL);

if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality,
upscale, TRUE, export_masks, icc_type,
upscale, is_scaling, scale_factor,
TRUE, export_masks, icc_type,
icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
{
dt_print(DT_DEBUG_ALWAYS,
Expand Down
8 changes: 6 additions & 2 deletions src/imageio/storage/gallery.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2011-2024 darktable developers.
Copyright (C) 2011-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -255,6 +255,8 @@ int store(dt_imageio_module_storage_t *self,
const int total,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean export_masks,
dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename,
Expand Down Expand Up @@ -395,7 +397,8 @@ int store(dt_imageio_module_storage_t *self,
// 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, TRUE, export_masks, icc_type,
upscale, is_scaling, scale_factor,
TRUE, export_masks, icc_type,
icc_filename, icc_intent, self, sdata, num, total, metadata) != 0)
{
dt_print(DT_DEBUG_ALWAYS,
Expand Down Expand Up @@ -436,6 +439,7 @@ int store(dt_imageio_module_storage_t *self,
ext = format->extension(fdata);
sprintf(c, "-thumb.%s", ext);
if(dt_imageio_export(imgid, filename, format, fdata, FALSE, TRUE, FALSE,
is_scaling, scale_factor,
export_masks, icc_type, icc_filename,
icc_intent, self, sdata, num, total, NULL) != 0)
{
Expand Down
6 changes: 4 additions & 2 deletions src/imageio/storage/imageio_storage_api.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2016-2023 darktable developers.
Copyright (C) 2016-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -67,7 +67,9 @@ OPTIONAL(int, initialize_store, struct dt_imageio_module_storage_t *self, struct
/* this actually does the work */
REQUIRED(int, store, struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *self_data, const dt_imgid_t 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 gboolean export_masks,
const int total, const gboolean high_quality, const gboolean upscale,
const gboolean is_scaling, const double scale_factor,
const gboolean export_masks,
const enum dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
enum dt_iop_color_intent_t icc_intent, struct dt_export_metadata_t *metadata);
/* called once at the end (after exporting all images), if implemented. */
Expand Down
6 changes: 4 additions & 2 deletions src/imageio/storage/latex.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2012-2024 darktable developers.
Copyright (C) 2012-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -224,7 +224,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 dt_imgid_t 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 export_masks,
const gboolean high_quality, const gboolean upscale, const gboolean is_scaling,
const double scale_factor, const gboolean export_masks,
dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent,
dt_export_metadata_t *metadata)
{
Expand Down Expand Up @@ -362,6 +363,7 @@ int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, co

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

Expand Down
6 changes: 4 additions & 2 deletions src/imageio/storage/piwigo.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2018-2024 darktable developers.
Copyright (C) 2018-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1271,6 +1271,8 @@ int store(dt_imageio_module_storage_t *self,
const int total,
const gboolean high_quality,
const gboolean upscale,
const gboolean is_scaling,
const double scale_factor,
const gboolean export_masks,
const dt_colorspaces_color_profile_type_t icc_type,
const gchar *icc_filename,
Expand Down Expand Up @@ -1353,8 +1355,8 @@ int store(dt_imageio_module_storage_t *self,
g_free(filename);

dt_image_cache_read_release(img);

if(dt_imageio_export(imgid, fname, format, fdata, high_quality, upscale,
is_scaling, scale_factor,
TRUE, export_masks, icc_type, icc_filename,
icc_intent, self, sdata, num, total, metadata) != 0)
{
Expand Down
3 changes: 2 additions & 1 deletion src/libs/print_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,11 @@ static int _export_image(dt_job_t *job, dt_image_box *img)
const gboolean upscale = TRUE;
const gboolean export_masks = FALSE;
const gboolean is_scaling = FALSE;
const double scale_factor = 1.0;

dt_imageio_export_with_flags
(img->imgid, "unused", &buf, (dt_imageio_module_data_t *)&dat, TRUE, FALSE,
high_quality, upscale, is_scaling, FALSE, NULL,
high_quality, upscale, is_scaling, scale_factor, FALSE, NULL,
FALSE, export_masks, params->buf_icc_type,
params->buf_icc_profile, params->buf_icc_intent, NULL, NULL, 1, 1, NULL, -1);

Expand Down
14 changes: 12 additions & 2 deletions src/lua/format.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2014-2023 darktable developers.
Copyright (C) 2014-2025 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -164,7 +164,17 @@ static int write_image(lua_State *L)
// TODO: expose icc overwrites to the user!
dt_colorspaces_color_profile_type_t icc_type = dt_conf_get_int("plugins/lighttable/export/icctype");
const char *icc_filename = dt_conf_get_string_const("plugins/lighttable/export/iccprofile");
gboolean result = dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, FALSE, export_masks,

// scaling
const gboolean is_scaling =
dt_conf_is_equal("plugins/lighttable/export/resizing", "scaling");

double _num, _denum;
dt_imageio_resizing_factor_get_and_parsing(&_num, &_denum);
const double scale_factor = is_scaling? _num / _denum : 1.0;

gboolean result = dt_imageio_export(imgid, filename, format, fdata, high_quality, upscale, is_scaling, scale_factor,
FALSE, export_masks,
icc_type, icc_filename, DT_INTENT_LAST, NULL, NULL, 1, 1, NULL);
dt_lua_lock();
// mitigate 17938 by returning sane values (true for success, false for failure)
Expand Down
Loading
Loading