From: Dan F. <dfa...@us...> - 2009-10-01 06:10:47
|
Update of /cvsroot/libexif/exif/exif In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11829/exif Modified Files: main.c utils.c utils.h Log Message: Added --no-fixup to disable attempts to fix tags in existing files. This involved creating a version of exif_loader_get_data (exif_get_data_opts) that allows ExifOption values to be set in the ExifData before it's used to store tags. Index: main.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/main.c,v retrieving revision 1.73 retrieving revision 1.74 diff -u -p -d -r1.73 -r1.74 --- main.c 22 Jan 2009 07:41:11 -0000 1.73 +++ main.c 1 Oct 2009 06:10:39 -0000 1.74 @@ -169,7 +169,7 @@ log_func (ExifLog *log, ExifLogCode code static unsigned int list_tags = 0, show_description = 0; static unsigned int xml_output = 0; static unsigned int extract_thumbnail = 0, remove_thumb = 0; -static unsigned int remove_tag = 0, create_exif = 0; +static unsigned int remove_tag = 0, create_exif = 0, no_fixup = 0; static unsigned int list_mnote = 0; static unsigned int show_version = 0; static const char *output = NULL; @@ -207,6 +207,8 @@ main (int argc, const char **argv) N_("Remove thumbnail"), NULL}, {"insert-thumbnail", 'n', POPT_ARG_STRING, &p.set_thumb, 0, N_("Insert FILE as thumbnail"), N_("FILE")}, + {"no-fixup", '\0', POPT_ARG_NONE, &no_fixup, 0, + N_("Do not fix existing tags in files"), NULL}, {"output", 'o', POPT_ARG_STRING, &output, 0, N_("Write data to FILE"), N_("FILE")}, {"set-value", '\0', POPT_ARG_STRING, &p.set_value, 0, @@ -351,7 +353,13 @@ main (int argc, const char **argv) log_arg.ignore_corrupted = 0; if (!log_arg.corrupted) create_exif = 0; - ed = exif_loader_get_data (l); + + if (no_fixup) + /* Override the default conversion options */ + ed = exif_get_data_opts(l, log, 0, EXIF_DATA_TYPE_UNKNOWN); + else + ed = exif_loader_get_data(l); + exif_loader_unref (l); if (!ed) { if (create_exif) { Index: utils.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/utils.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -p -d -r1.13 -r1.14 --- utils.c 20 Jan 2009 23:47:29 -0000 1.13 +++ utils.c 1 Oct 2009 06:10:39 -0000 1.14 @@ -74,6 +74,39 @@ exif_ifd_from_string (const char *string return (-1); } +/*! An alternative to exif_loader_get_data() that allows the options and + * data type to be set. + * + * \param[in] loader the loader + * \param[in] options one or more bitwise ORred options from ExifDataOption + * \param[in] dt image data type + * \return allocated ExifData + */ +ExifData * +exif_get_data_opts(ExifLoader *loader, ExifLog *log, + int options, ExifDataType dt) +{ + ExifData *ed; + const unsigned char *buf; + size_t buf_size; + + if (!loader || !log) + return NULL; + + exif_loader_get_buf (loader, &buf, &buf_size); + if (buf_size == 0) + return NULL; + ed = exif_data_new(); + exif_data_log (ed, log); + + /* Clear the slate before setting the requested options */ + exif_data_unset_option (ed, ~0); + exif_data_set_option (ed, options); + exif_data_set_data_type (ed, dt); + exif_data_load_data (ed, buf, buf_size); + + return ed; +} /*! Returns the number of bytes of data needed to display n characters of * the given multibyte string in the current locale character encoding. @@ -84,6 +117,7 @@ exif_ifd_from_string (const char *string * by the returned number of bytes (this may be less but never more than the * value on entry) * \return number of bytes starting at mbs make up len characters + * \note This can probably be rewritten using mbsrtowcs() */ #ifdef HAVE_MBLEN size_t exif_mbstrlen(const char *mbs, size_t *len) Index: utils.h =================================================================== RCS file: /cvsroot/libexif/exif/exif/utils.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -p -d -r1.8 -r1.9 --- utils.h 13 Jan 2009 08:51:41 -0000 1.8 +++ utils.h 1 Oct 2009 06:10:39 -0000 1.9 @@ -24,11 +24,13 @@ #include <sys/types.h> #include <libexif/exif-tag.h> #include <libexif/exif-ifd.h> +#include <libexif/exif-loader.h> enum {EXIF_INVALID_TAG = 0xffff}; ExifTag exif_tag_from_string (const char *string); ExifIfd exif_ifd_from_string (const char *string); +ExifData *exif_get_data_opts(ExifLoader *loader, ExifLog *log, int options, ExifDataType dt); size_t exif_mbstrlen(const char *mbs, size_t *len); #endif /* __UTILS_H__ */ |