exif.h 3.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
    This file is part of darktable,
    copyright (c) 2009--2010 johannes hanika.

    darktable is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    darktable is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with darktable.  If not, see <http://www.gnu.org/licenses/>.
*/
jhanika's avatar
jhanika committed
18

19
#pragma once
jhanika's avatar
jhanika committed
20

21
#include "common/colorspaces.h"
22
#include "common/image.h"
jhanika's avatar
jhanika committed
23 24 25

/** wrapper around exiv2, C++ */
#ifdef __cplusplus
26
extern "C" {
jhanika's avatar
jhanika committed
27 28
#endif

29 30 31
/** read metadata from file with full path name, XMP data trumps IPTC data trumps EXIF data, store to image
 * struct. returns 0 on success. */
int dt_exif_read(dt_image_t *img, const char *path);
jhanika's avatar
jhanika committed
32

33 34
/** read exif data to image struct from given data blob, wherever you got it from. */
int dt_exif_read_from_blob(dt_image_t *img, uint8_t *blob, const int size);
35

36
/** write exif to blob, return length in bytes. blob will be allocated by the function. sRGB should be true
37
 * if sRGB colorspace is used as output. */
38
int dt_exif_read_blob(uint8_t **blob, const char *path, const int imgid, const int sRGB, const int out_width,
39
                      const int out_height, const int dng_mode);
jhanika's avatar
jhanika committed
40

41
/** write blob to file exif. merges with existing exif information.*/
42
int dt_exif_write_blob(uint8_t *blob, uint32_t size, const char *path, const int compressed);
43

44 45
/** write xmp sidecar file. */
int dt_exif_xmp_write(const int imgid, const char *filename);
46

47 48
/** write xmp packet inside an image. */
int dt_exif_xmp_attach(const int imgid, const char *filename);
49

50 51 52
/** get the xmp blob for imgid. */
char *dt_exif_xmp_read_string(const int imgid);

53 54
/** read xmp sidecar file. */
int dt_exif_xmp_read(dt_image_t *img, const char *filename, const int history_only);
55

56
/** fetch largest exif thumbnail jpg bytestream into buffer*/
57
int dt_exif_get_thumbnail(const char *path, uint8_t **buffer, size_t *size, char **mime_type);
58

59 60 61
/** thread safe init and cleanup. */
void dt_exif_init();
void dt_exif_cleanup();
62

63 64
/** encode / decode op params */
char *dt_exif_xmp_encode(const unsigned char *input, const int len, int *output_len);
65
char *dt_exif_xmp_encode_internal(const unsigned char *input, const int len, int *output_len, gboolean do_compress);
66
unsigned char *dt_exif_xmp_decode(const char *input, const int len, int *output_len);
67

68 69 70
/** look for color space hints in data and tell the caller if it's sRGB, AdobeRGB or something else. used for mipmaps */
dt_colorspaces_color_profile_type_t dt_exif_get_color_space(const uint8_t *data, size_t size);

Tobias Ellinghaus's avatar
Tobias Ellinghaus committed
71 72 73
/** look for datetime_taken in data. used for gphoto downloads */
gboolean dt_exif_get_datetime_taken(const uint8_t *data, size_t size, time_t *datetime_taken);

jhanika's avatar
jhanika committed
74 75 76 77
#ifdef __cplusplus
}
#endif

Richard Wonka's avatar
Richard Wonka committed
78
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
79
// vim: shiftwidth=2 expandtab tabstop=2 cindent
Tobias Ellinghaus's avatar
Tobias Ellinghaus committed
80
// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;