Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
image_extensions.h
Go to the documentation of this file.
1/*
2 This file is part of the Ansel project.
3 Copyright (C) 2023-2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef DT_COMMON_IMAGE_EXTENSIONS_H
19#define DT_COMMON_IMAGE_EXTENSIONS_H
20
21#include <glib.h>
22
25gboolean dt_supported_image(const gchar *filename);
26
27#include <glib.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/* Single source of truth for "what kind of image is this extension" across the whole app:
34 * decoder routing (dt_imageio_open()), the provisional img->flags guess
35 * (dt_image_flags_from_extension()), dt_supported_image(), and the import dialog's
36 * Raw/Raster GUI filter. Each of raw/ldr/hdr below has exactly one list per extension --
37 * mirroring the decoder-dispatch reality (dt_imageio_open_raw/_raster/_hdr are 3 distinct
38 * codec chains) -- entries are gated behind the same HAVE_* macros the codecs themselves use,
39 * so an extension is never reported as available when its codec isn't actually compiled in. */
40
41/* Decode routing + dt_supported_image(): exactly one of these is true per extension (except the
42 * handful covered by dt_image_ext_is_ambiguous(), which still route through exactly one of
43 * these three, but must not have a flag guessed from the extension alone -- see below).
44 *
45 * There is deliberately no plain "is_raster" (ldr || hdr) helper here: dt_imageio_open() has two
46 * DISTINCT decoder chains for ldr (dt_imageio_open_raster, generic/exotic-capable) and hdr
47 * (dt_imageio_open_hdr, OpenEXR/Radiance/PFM/AVIF/HEIF). Collapsing them would let the generic
48 * chain be tried before the dedicated one for an hdr-only extension. Combine is_ldr()/is_hdr()
49 * explicitly at each call site instead, so the distinction can't be silently lost again. */
50gboolean dt_image_ext_is_raw(const char *ext);
51gboolean dt_image_ext_is_ldr(const char *ext);
52gboolean dt_image_ext_is_hdr(const char *ext);
53gboolean dt_image_ext_is_supported(const char *ext); // raw || ldr || hdr
54
55/* Containers whose actual dynamic range (or, for dng, raw-vs-already-processed nature) cannot be
56 * known from the extension alone -- only after decoding. dt_image_flags_from_extension()
57 * must return 0 (unknown) for these instead of guessing from dt_image_ext_is_raw/_ldr/_hdr, even
58 * though they do route to one of the 3 decoders above. See doc/image-type-detection.md. */
59gboolean dt_image_ext_is_ambiguous(const char *ext);
60
61/* GUI-facing "Raw image files" / "Raster image files" buckets for the import dialog's file
62 * filter (common/import.c). Mostly mirror is_raw()/is_raster() above, plus one deliberate UX
63 * override: a linear/already-demosaiced DNG behaves like a normal processed photo, so dng is
64 * shown under both buckets rather than raw-only. This is a display-only concern -- it must
65 * never influence decoder routing. */
66gboolean dt_image_ext_is_gui_raw(const char *ext);
67gboolean dt_image_ext_is_gui_raster(const char *ext); // ldr || hdr || the dng override
68
69/* Read-only access to the 3 routing lists (NULL-terminated), so a caller that needs to build a
70 * GtkFileFilter pattern list (common/import.c) can enumerate every known extension instead of
71 * hand-maintaining its own copy. Filter membership (raw/ldr/hdr) with the is_*() predicates
72 * above -- do not assume list order or that raw/ldr/hdr partition disjointly for GUI purposes
73 * (dt_image_ext_is_gui_raster() can be true for an extension physically stored in the raw list). */
74const char *const *dt_image_ext_raw_list(void);
75const char *const *dt_image_ext_ldr_list(void);
76const char *const *dt_image_ext_hdr_list(void);
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif // DT_COMMON_IMAGE_EXTENSIONS_H
83
84// clang-format off
85// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
86// vim: shiftwidth=2 expandtab tabstop=2 cindent
87// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
88// clang-format on
gboolean dt_image_ext_is_ambiguous(const char *ext)
const char *const * dt_image_ext_ldr_list(void)
gboolean dt_image_ext_is_supported(const char *ext)
gboolean dt_image_ext_is_ldr(const char *ext)
gboolean dt_image_ext_is_gui_raw(const char *ext)
gboolean dt_image_ext_is_gui_raster(const char *ext)
const char *const * dt_image_ext_raw_list(void)
const char *const * dt_image_ext_hdr_list(void)
gboolean dt_supported_image(const gchar *filename)
Definition darktable.c:382
gboolean dt_image_ext_is_raw(const char *ext)
gboolean dt_image_ext_is_hdr(const char *ext)