111#if defined(HAVE_GRAPHICSMAGICK)
112#include <magick/api.h>
113#include <magick/blob.h>
114#elif defined(HAVE_IMAGEMAGICK)
115#include <MagickWand/MagickWand.h>
119#include <glib/gstdio.h>
144#if defined(HAVE_GRAPHICSMAGICK)
187 sizeof(uint8_t) * 4 *
jpg.width *
jpg.height,
189 if(!*buffer)
goto error;
206#if defined(HAVE_GRAPHICSMAGICK)
238 fprintf(
stderr,
"[dt_imageio_large_thumbnail GM] thumbnail not found?\n");
247 sizeof(uint8_t) * 4 * image->columns * image->rows,
251 for(uint32_t
row = 0;
row < image->rows;
row++)
253 uint8_t *
bufprt = *buffer + (size_t)4 *
row * image->columns;
260 fprintf(
stderr,
"[dt_imageio_large_thumbnail GM] error_gm reading thumbnail\n");
276#elif defined(HAVE_IMAGEMAGICK)
300 fprintf(
stderr,
"[dt_imageio_large_thumbnail IM] thumbnail not found?\n");
312 "[dt_imageio_large_thumbnail IM] could not map colorspace, using sRGB");
324 "[dt_imageio_large_thumbnail IM] error while reading thumbnail\n");
336 "[dt_imageio_large_thumbnail] error: The thumbnail image is not in "
337 "JPEG format, and DT was built without neither GraphicsMagick or "
338 "ImageMagick. Please rebuild DT with GraphicsMagick or ImageMagick "
339 "support enabled.\n");
347 "[dt_imageio_large_thumbnail] error: Not a supported thumbnail image format or broken thumbnail: %s\n",
384 const uint8_t *
const source = buffer + 4 * ((size_t)(
j +
top) *
in_width + left);
398 int32_t thumb_width = 0, thumb_height = 0;
403 if((thumb_width < 32) || (thumb_height < 32) || (
IS_NULL_PTR(
tmp)))
407 for(
int y = 0; y < thumb_height; y++)
409 uint8_t *
in = (uint8_t *)
tmp + (
size_t)4 * y * thumb_width;
410 for(
int x = 0;
x < thumb_width;
x++,
in += 4)
412 if((
in[0] !=
in[1]) || (
in[0] !=
in[2]) || (
in[1] !=
in[2]))
429 const int fwd,
const int fht,
const int stride,
456 for(
int j = 0;
j < ht;
j++)
459 const char *
in2 =
in + (size_t)stride *
j;
460 for(
int i = 0;
i < wd;
i++)
470 const int ch,
const int wd,
const int ht,
const int fwd,
471 const int fht,
const int stride,
474 const float scale = 1.0f / (white - black);
478 for(
int j = 0;
j < ht;
j++)
479 for(
int i = 0;
i < wd;
i++)
480 for(
int k = 0;
k <
ch;
k++)
481 out[4 * ((
size_t)
j * wd +
i) +
k] = (
in[(size_t)
j * stride + (
size_t)
ch *
i +
k] - black) * scale;
485 int si = 4,
sj = wd * 4;
502 for(
int j = 0;
j < ht;
j++)
505 const uint8_t *
in2 =
in + (size_t)stride *
j;
506 for(
int i = 0;
i < wd;
i++)
562 const char *c = filename +
strlen(filename);
563 while(c > filename && *c !=
'.') c--;
564 if(*c !=
'.')
return FALSE;
570 const char *c = filename +
strlen(filename);
571 while(c > filename && *c !=
'.') c--;
572 if(*c !=
'.')
return FALSE;
578 const char *c = filename +
strlen(filename);
579 while(c > filename && *c !=
'.') c--;
580 if(*c !=
'.')
return FALSE;
587 gboolean success =
FALSE;
719 *num = (int)(
in * *
den + .5f);
720 while(
fabsf(*num / (
float)*
den -
in) > 0.001f)
723 *num = (int)(
in * *
den + .5f);
736 return format->write_image(
format_params, filename,
NULL, icc_type, icc_filename,
NULL, 0, imgid, num, total,
NULL,
812 int width,
int height,
int *processed_width,
int *processed_height)
890 const size_t processed_height)
893 for(
size_t k = 0;
k < processed_width * processed_height;
k++)
900 const size_t processed_width,
const size_t processed_height)
903 for(
size_t k = 0;
k < processed_width * processed_height;
k++)
914 const size_t processed_width,
const size_t processed_height)
917 for(
size_t k = 0;
k < processed_width * processed_height;
k++)
927 const char *filter,
const gboolean
copy_metadata,
const gboolean export_masks,
986 const size_t buf_width = buf.
width;
987 const size_t buf_height = buf.
height;
1017 int processed_width = 0;
1018 int processed_height = 0;
1020 &processed_width, &processed_height);
1023 "[dt_imageio_export] (direct) image input %ix%i, turned to output %ix%i, will be exported to fit %ix%i "
1024 "--> final size is %ix%i\n",
1036 :
"[dev_process_export] pixel pipeline processing thread");
1054 &
data, &cache_entry)
1071 sizeof(uint8_t) * pixels,
1093 sizeof(uint16_t) * pixels,
1149 num, total, &pipe, export_masks);
1190#if defined(HAVE_GRAPHICSMAGICK)
1192#elif defined(HAVE_IMAGEMAGICK)
1206 const char *filename,
1244 fprintf(
stderr,
"[imageio] The file %s is supported by none of our decoders.\n", filename);
1245 dt_control_log(
_(
"The file `%s` is supported by none of our decoders."), filename);
1265 memset(buf, 0,
sizeof(*buf));
static void error(char *msg)
void cleanup(dt_imageio_module_format_t *self)
The colour-profile module's API: which profiles exist, and how to apply one.
static dt_aligned_pixel_t sRGB
const dt_colormatrix_t dt_aligned_pixel_t out
gchar * dt_conf_get_string(const char *name)
gboolean dt_conf_is_equal(const char *name, const char *value)
void dt_image_buffer_resolve_flags(dt_image_t *img)
void dt_image_full_path(const int32_t imgid, char *pathname, size_t pathname_len, gboolean *from_cache, const char *calling_func)
Get the full path of an image out of the database.
void dt_control_log(const char *msg,...)
void dt_dev_pop_history_items(dt_develop_t *dev)
Thread-safe wrapper around dt_dev_pop_history_items_ext(), then update GUI.
void dt_dev_pixelpipe_propagate_formats(dt_dev_pixelpipe_t *pipe)
void dt_dev_pixelpipe_get_roi_out(dt_dev_pixelpipe_t *pipe, const int width_in, const int height_in, int *width, int *height)
void dt_dev_cleanup(dt_develop_t *dev)
dt_dev_image_storage_t dt_dev_load_image(dt_develop_t *dev, const int32_t imgid)
void dt_dev_init(dt_develop_t *dev, int32_t gui_attached)
int dt_exif_get_thumbnail(const char *path, uint8_t **buffer, size_t *size, char **mime_type, int *width, int *height, int min_width)
What a photograph says about itself: the EXIF, IPTC and XMP tags a camera and a cataloguer write,...
float dt_boundingbox_t[4]
@ DT_IMAGEIO_FILE_CORRUPTED
gboolean dt_image_ext_is_ldr(const char *ext)
gboolean dt_image_ext_is_raw(const char *ext)
gboolean dt_image_ext_is_hdr(const char *ext)
dt_imageio_retval_t dt_imageio_open_avif(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
int dt_imageio_export_with_flags(const int32_t imgid, const char *filename, dt_imageio_module_format_t *format, dt_imageio_module_data_t *format_params, const gboolean ignore_exif, const gboolean display_byteorder, const gboolean high_quality, gboolean is_scaling, const gboolean thumbnail_export, const char *filter, const gboolean copy_metadata, const gboolean export_masks, 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, dt_export_metadata_t *metadata, dt_atomic_int *shutdown)
void _clamp_float_to_uint8(const float *const inbuf, uint8_t *const outbuf, const size_t processed_width, const size_t processed_height)
void dt_imageio_flip_buffers_ui8_to_float(float *out, const uint8_t *in, const float black, const float white, const int ch, const int wd, const int ht, const int fwd, const int fht, const int stride, const dt_image_orientation_t orientation)
int dt_imageio_is_hdr(const char *filename)
gboolean dt_imageio_lookup_makermodel(const char *maker, const char *model, char *mk, int mk_len, char *md, int md_len, char *al, int al_len)
dt_imageio_retval_t dt_imageio_open(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
int dt_imageio_export(const int32_t imgid, const char *filename, dt_imageio_module_format_t *format, dt_imageio_module_data_t *format_params, const gboolean high_quality, const gboolean copy_metadata, const gboolean export_masks, 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, dt_export_metadata_t *metadata)
void dt_imageio_close_standalone(dt_mipmap_buffer_t *buf)
Release a buffer from dt_imageio_open_standalone(). NULL-safe, and safe to call on a buffer whose ope...
void _swap_byteorder_float_to_uint8(const float *const restrict inbuf, uint8_t *const outbuf, const size_t processed_width, const size_t processed_height)
dt_imageio_retval_t dt_imageio_open_raster(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
void _filter_pipeline(const char *filter, dt_dev_pixelpipe_t *pipe)
dt_imageio_retval_t dt_imageio_open_standalone(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
Decode a file into a buffer the CALLER owns, with no cache involvement.
gboolean dt_imageio_is_raster(const char *filename)
gboolean dt_imageio_has_mono_preview(const char *filename)
void dt_imageio_to_fractional(float in, uint32_t *num, uint32_t *den)
gboolean dt_imageio_crop_thumbnail(const dt_boundingbox_t box, uint8_t *const buffer, int32_t *width, int32_t *height)
Crop an 8-bit RGBA preview buffer in place to a normalized bounding box.
gboolean dt_imageio_is_handled_by_libraw(dt_image_t *img, const char *filename)
gboolean _get_export_size(dt_develop_t *dev, dt_dev_pixelpipe_t *pipe, const dt_imageio_module_data_t *format_params, const gboolean is_scaling, double *scale, int width, int height, int *processed_width, int *processed_height)
gboolean _apply_style_before_export(dt_develop_t *dev, dt_imageio_module_data_t *format_params, const int32_t imgid)
dt_imageio_retval_t dt_imageio_open_hdr(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
dt_imageio_retval_t dt_imageio_open_raw(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
static gboolean _is_in_list(char *elem, char *list)
gboolean dt_imageio_is_raw(const char *filename)
dt_imageio_retval_t dt_imageio_open_exotic(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
int dt_imageio_large_thumbnail(const char *filename, uint8_t **buffer, int32_t *th_width, int32_t *th_height, dt_colorspaces_color_profile_type_t *color_space, const int width, const int height)
Map Exiv2 preview MIME types to decoder format identifiers.
void _print_export_debug(dt_dev_pixelpipe_t *pipe, dt_imageio_module_data_t *format_params, const gboolean use_style)
__DT_CLONE_TARGETS__ void dt_imageio_flip_buffers(char *out, const char *in, const size_t bpp, const int wd, const int ht, const int fwd, const int fht, const int stride, const dt_image_orientation_t orientation)
void _export_final_buffer_to_uint16(const float *const restrict inbuf, uint16_t *const outbuf, const size_t processed_width, const size_t processed_height)
dt_imageio_retval_t dt_imageio_open_exr(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_gm(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
dt_imageio_retval_t dt_imageio_open_heif(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_im(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
dt_imageio_retval_t dt_imageio_open_j2k(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
int dt_imageio_jpeg_decompress_header(const void *in, size_t length, dt_imageio_jpeg_t *jpg)
dt_imageio_retval_t dt_imageio_open_jpeg(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
int dt_imageio_jpeg_decompress(dt_imageio_jpeg_t *jpg, uint8_t *out)
dt_imageio_retval_t dt_imageio_open_libraw(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
gboolean dt_libraw_lookup_makermodel(const char *maker, const char *model, char *mk, int mk_len, char *md, int md_len, char *al, int al_len)
gchar * dt_imageio_resizing_factor_get_and_parsing(double *num, double *denum)
@ FORMAT_FLAGS_SUPPORT_XMP
@ FORMAT_FLAGS_NO_TMPFILE
dt_imageio_retval_t dt_imageio_open_pfm(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_png(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_pnm(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
const dt_colorspaces_color_profile_t * dt_colorspaces_get_output_profile(const int32_t imgid, dt_colorspaces_color_profile_type_t *over_type, const char *over_filename)
gboolean dt_rawspeed_lookup_makermodel(const char *maker, const char *model, char *mk, int mk_len, char *md, int md_len, char *al, int al_len)
dt_imageio_retval_t dt_imageio_open_rawspeed(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_rgbe(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_tiff(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
dt_imageio_retval_t dt_imageio_open_webp(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
void dt_ioppr_resync_modules_order(dt_develop_t *dev)
Update dev->iop module order values from dev->iop_order_list.
void dt_ioppr_update_for_style_items(dt_develop_t *dev, GList *st_items, gboolean append)
Update dev->iop_order_list with modules referenced by style items.
int dt_ioppr_check_iop_order(dt_develop_t *dev, const int32_t imgid, const char *msg)
Debug helper to validate the current order for a develop context.
int32_t dt_get_debug_flags(void)
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define CLAMPF(a, mn, mx)
dt_colorspaces_color_profile_type_t color_space
#define dt_mipmap_cache_get(B, C, D, E, F)
#define dt_mipmap_cache_release(B)
#define __OMP_PARALLEL_FOR__(...)
void dt_dev_pixelpipe_cache_ref_count_entry(gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Increase/Decrease the reference count on the cache line as to prevent LRU item removal....
void dt_dev_pixelpipe_cache_rdlock_entry(gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the read lock on the entry.
gboolean dt_dev_pixelpipe_cache_ref_entry_by_hash(const uint64_t hash, void **data, dt_pixel_cache_entry_t **entry)
Resolve and retain an existing cache entry by hash.
#define dt_pixelpipe_cache_alloc_align_cache(size, id)
#define dt_pixelpipe_cache_free_align(mem)
void dt_dev_pixelpipe_set_input(dt_dev_pixelpipe_t *pipe, int32_t imgid, int width, int height, float iscale, dt_mipmap_size_t size)
void dt_dev_pixelpipe_disable_before(dt_dev_pixelpipe_t *pipe, const char *op)
void dt_dev_pixelpipe_disable_after(dt_dev_pixelpipe_t *pipe, const char *op)
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)
void dt_dev_pixelpipe_create_nodes(dt_dev_pixelpipe_t *pipe)
int dt_dev_pixelpipe_init_thumbnail(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
int dt_dev_pixelpipe_init_export(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, int levels, gboolean store_masks)
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe)
int dt_dev_pixelpipe_process(dt_dev_pixelpipe_t *pipe, dt_iop_roi_t roi)
#define dt_dev_pixelpipe_synch_all(pipe)
static uint64_t dt_dev_backbuf_get_hash(const dt_backbuf_t *backbuf)
dt_iop_color_intent_t
ICC rendering intent, as stored in iop params and in conf.
dt_colorspaces_color_profile_type_t
@ DT_COLORSPACE_SRGB
sRGB – registered TWICE, and the two entries are not interchangeable.
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
struct dt_control_signal_t * dt_control_signal_get_global(void)
@ DT_SIGNAL_IMAGE_EXPORT_TMPFILE
This signal is raised after an image has been exported to a file, but before it is sent to facebook/p...
#define for_four_channels(_var,...)
void dt_cache_entry_free_detached(dt_cache_entry_t *entry)
Release an entry from dt_cache_entry_new_detached(), and its data. NULL-safe.
dt_cache_entry_t * dt_cache_entry_new_detached(void)
Allocate a cache entry that belongs to NO cache, for a one-shot decode.
GList * dt_styles_get_item_list(const char *name, gboolean params, int32_t imgid)
void dt_styles_apply_style_item(dt_develop_t *dev, dt_style_item_t *style_item)
void dt_style_item_free(gpointer data)
struct dt_iop_module_t *void * data
dt_atomic_int * shutdown_ext
Region of interest passed through the pixelpipe.
dt_cache_entry_t * cache_entry
#define __DT_CLONE_TARGETS__
typedef double((*spd)(unsigned long int wavelength, double TempK))
void dt_show_times(const dt_times_t *start, const char *prefix)
static void dt_get_times(dt_times_t *t)
Telling the user something happened.
int dt_exif_xmp_attach_export(const int32_t imgid, const char *filename, void *metadata)
int dt_exif_read_blob(uint8_t **buf, const char *path, const int32_t imgid, const int sRGB, const int out_width, const int out_height, const int dng_mode)
The XMP document that carries an image's development: history stack, mask shapes, module order,...