1 /* 2 This file is part of darktable, 3 Copyright (C) 2009-2020 darktable developers. 4 5 darktable 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 darktable 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 darktable. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #pragma once 20 21 #include "common/colorspaces.h" 22 #include "common/image.h" 23 24 /** wrapper around exiv2, C++ */ 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /** set the list of available tags from Exvi2 */ 30 void dt_exif_set_exiv2_taglist(); 31 32 /** get the list of available tags from Exvi2 */ 33 /** must not be freed */ 34 const GList* dt_exif_get_exiv2_taglist(); 35 36 /** read metadata from file with full path name, XMP data trumps IPTC data trumps EXIF data, store to image 37 * struct. returns 0 on success. */ 38 int dt_exif_read(dt_image_t *img, const char *path); 39 40 /** read exif data to image struct from given data blob, wherever you got it from. */ 41 int dt_exif_read_from_blob(dt_image_t *img, uint8_t *blob, const int size); 42 43 /** write exif to blob, return length in bytes. blob will be allocated by the function. sRGB should be true 44 * if sRGB colorspace is used as output. */ 45 int dt_exif_read_blob(uint8_t **blob, const char *path, const int imgid, const int sRGB, const int out_width, 46 const int out_height, const int dng_mode); 47 48 /** Reads exif DefaultUserCrop */ 49 void dt_exif_img_check_usercrop(dt_image_t *img, const char *filename); 50 51 /** write blob to file exif. merges with existing exif information.*/ 52 int dt_exif_write_blob(uint8_t *blob, uint32_t size, const char *path, const int compressed); 53 54 /** write xmp sidecar file. */ 55 int dt_exif_xmp_write(const int imgid, const char *filename); 56 57 /** write xmp packet inside an image. */ 58 int dt_exif_xmp_attach_export(const int imgid, const char *filename, void *metadata); 59 60 /** get the xmp blob for imgid. */ 61 char *dt_exif_xmp_read_string(const int imgid); 62 63 /** read xmp sidecar file. */ 64 int dt_exif_xmp_read(dt_image_t *img, const char *filename, const int history_only); 65 66 /** apply default import metadata */ 67 void dt_exif_apply_default_metadata(dt_image_t *img); 68 69 /** fetch largest exif thumbnail jpg bytestream into buffer*/ 70 int dt_exif_get_thumbnail(const char *path, uint8_t **buffer, size_t *size, char **mime_type); 71 72 /** thread safe init and cleanup. */ 73 void dt_exif_init(); 74 void dt_exif_cleanup(); 75 76 /** encode / decode op params */ 77 char *dt_exif_xmp_encode(const unsigned char *input, const int len, int *output_len); 78 char *dt_exif_xmp_encode_internal(const unsigned char *input, const int len, int *output_len, gboolean do_compress); 79 unsigned char *dt_exif_xmp_decode(const char *input, const int len, int *output_len); 80 81 /** look for color space hints in data and tell the caller if it's sRGB, AdobeRGB or something else. used for mipmaps */ 82 dt_colorspaces_color_profile_type_t dt_exif_get_color_space(const uint8_t *data, size_t size); 83 84 /** look for datetime_taken in data. used for gphoto downloads */ 85 gboolean dt_exif_get_datetime_taken(const uint8_t *data, size_t size, time_t *datetime_taken); 86 87 #ifdef __cplusplus 88 } 89 #endif 90 91 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh 92 // vim: shiftwidth=2 expandtab tabstop=2 cindent 93 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified; 94