Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
image_extensions.c
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*/
19#include "system/macros.h"
20
21#include <string.h>
22
23/* These 3 lists are the decode-routing ground truth: each extension appears in AT MOST one of
24 * them. Do NOT list an extension in more than one -- dt_imageio_open() tries the matching
25 * decoder(s) in order and a generic/exotic fallback can silently "succeed" on data it
26 * misinterprets (e.g. GraphicsMagick reading a .dng's embedded TIFF structure as a normal image
27 * instead of letting rawspeed/libraw demosaic the actual sensor data). Ambiguity about the
28 * eventual *class* of a file (raw-vs-processed, LDR-vs-HDR) is handled separately by
29 * dt_image_ext_is_ambiguous() below, which never adds a second routing entry. */
30
31static const char *_raw_extensions[] = {
32 "3fr", "ari", "arw", "bay", "bmq", "cap", "cine", "cr2",
33 "crw", "cs1", "dc2", "dcr", "dng", "gpr", "erf", "fff",
34 "ia", "iiq", "k25", "kc2", "kdc", "mdc", "mef", "mos",
35 "mrw", "nef", "nrw", "orf", "ori", "pef", "pxn", "qtk",
36 "raf", "raw", "rdc", "rw2", "rwl", "sr2", "srf", "srw", "x3f",
37#ifdef HAVE_LIBRAW
38 "cr3",
39#endif
40 NULL
41};
42
43static const char *_ldr_extensions[] = {
44 "jpg", "jpeg", "png", "tif", "tiff", "pgm", "pbm", "ppm",
45#ifdef HAVE_OPENJPEG
46 "jp2", "j2k", "jpc",
47#endif
48#ifdef HAVE_WEBP
49 "webp",
50#endif
51#if defined(HAVE_GRAPHICSMAGICK) || defined(HAVE_IMAGEMAGICK)
52 // Formats only reachable through the generic exotic decoder inside dt_imageio_open_raster(),
53 // gated on the same libraries CMake requires to actually decode them (src/CMakeLists.txt).
54 "gif", "bmp", "dcm", "jng", "miff", "mng", "pnm", "pam",
55#endif
56 NULL
57};
58
59static const char *_hdr_extensions[] = {
60 "pfm", "hdr",
61#ifdef HAVE_OPENEXR
62 "exr",
63#endif
64#ifdef HAVE_LIBAVIF
65 "avif",
66#endif
67#ifdef HAVE_LIBHEIF
68 "heif", "heic", "hif",
69#endif
70 NULL
71};
72
73/* Containers whose real class needs a decode to settle -- see doc/image-type-detection.md.
74 * Each of these still appears in exactly one of the 3 lists above (for routing); this list only
75 * suppresses guessing a flag from the extension in dt_image_flags_from_extension(). */
76static const char *_ambiguous_extensions[] = {
77 "dng", "tif", "tiff", "heif", "heic", "avif", "hif", NULL
78};
79
80/* Extensions shown under both GUI buckets in the import dialog despite having a single routing
81 * category -- a display-only nicety, never consulted by decoder routing. */
82static const char *_gui_dual_bucket_extensions[] = { "dng", NULL };
83
84static gboolean _ext_in_list(const char *ext, const char *const *list)
85{
86 if(IS_NULL_PTR(ext)) return FALSE;
87 for(; *list; list++)
88 if(!g_ascii_strncasecmp(ext, *list, strlen(*list)))
89 return TRUE;
90 return FALSE;
91}
92
93gboolean dt_image_ext_is_raw(const char *ext)
94{
96}
97
98gboolean dt_image_ext_is_ldr(const char *ext)
99{
101}
102
103gboolean dt_image_ext_is_hdr(const char *ext)
104{
106}
107
112
113gboolean dt_image_ext_is_ambiguous(const char *ext)
114{
116}
117
118gboolean dt_image_ext_is_gui_raw(const char *ext)
119{
120 return dt_image_ext_is_raw(ext);
121}
122
127
128const char *const *dt_image_ext_raw_list(void) { return _raw_extensions; }
129const char *const *dt_image_ext_ldr_list(void) { return _ldr_extensions; }
130const char *const *dt_image_ext_hdr_list(void) { return _hdr_extensions; }
131
132// clang-format off
133// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
134// vim: shiftwidth=2 expandtab tabstop=2 cindent
135// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
136// clang-format on
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
static gboolean _ext_in_list(const char *ext, const char *const *list)
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)
static const char * _raw_extensions[]
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)
static const char * _ambiguous_extensions[]
gboolean dt_image_ext_is_raw(const char *ext)
static const char * _hdr_extensions[]
static const char * _ldr_extensions[]
gboolean dt_image_ext_is_hdr(const char *ext)
static const char * _gui_dual_bucket_extensions[]
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:65