From: <lu...@us...> - 2002-10-21 19:48:09
|
Update of /cvsroot/libexif/exif/exif In directory usw-pr-cvs1:/tmp/cvs-serv18361/exif Modified Files: main.c Log Message: 2002-10-21 Lutz Müller <lu...@us...> * exif/main.c: --remove-thumbnail and --remove [tag] as requested by Marko Mäkelä <Mar...@HU...>. Index: main.c =================================================================== RCS file: /cvsroot/libexif/exif/exif/main.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- main.c 15 Sep 2002 21:55:27 -0000 1.21 +++ main.c 21 Oct 2002 19:48:06 -0000 1.22 @@ -193,7 +193,8 @@ { /* POPT_ARG_NONE needs an int, not char! */ unsigned int list_tags = 0, show_description = 0; - unsigned int extract_thumbnail = 0; + unsigned int extract_thumbnail = 0, remove_thumbnail = 0; + unsigned int remove_tag = 0; const char *set_value = NULL, *ifd_string = NULL, *tag_string = NULL; ExifIfd ifd = -1; ExifTag tag = 0; @@ -211,10 +212,14 @@ N_("Select IFD"), N_("IFD")}, {"list-tags", 'l', POPT_ARG_NONE, &list_tags, 0, N_("List all EXIF tags"), NULL}, + {"remove", '\0', POPT_ARG_NONE, &remove_tag, 0, + N_("Remove tag"), NULL}, {"show-description", 's', POPT_ARG_NONE, &show_description, 0, N_("Show description of tag"), NULL}, {"extract-thumbnail", 'e', POPT_ARG_NONE, &extract_thumbnail, 0, N_("Extract thumbnail"), NULL}, + {"remove-thumbnail", 'r', POPT_ARG_NONE, &remove_thumbnail, 0, + N_("Remove thumbnail"), NULL}, {"insert-thumbnail", 'n', POPT_ARG_STRING, &ithumbnail, 0, N_("Insert FILE as thumbnail"), N_("FILE")}, {"output", 'o', POPT_ARG_STRING, &output, 0, @@ -359,6 +364,15 @@ fname); fprintf (stdout, "\n"); + } else if (remove_thumbnail) { + + /* Get rid of the thumbnail */ + if (ed->data) { + free (ed->data); + ed->data = NULL; + } + ed->size = 0; + } else if (ithumbnail) { /* Get rid of the old thumbnail */ @@ -368,6 +382,7 @@ } ed->size = 0; + /* Insert new thumbnail */ f = fopen (ithumbnail, "rb"); if (!f) { #ifdef __GNUC__ @@ -511,6 +526,35 @@ } } save_exif_data_to_file (ed, *args, fname); + } else if (remove_tag) { + + /* We need a tag... */ + if (!tag) { + fprintf (stderr, _("You need to " + "specify a tag!")); + fputc ('\n', stderr); + return (1); + } + + /* ... and an IFD. */ + if (ifd < 0) { + fprintf (stderr, _("You need to " + "specify an IFD!")); + fputc ('\n', stderr); + return (1); + } + + e = exif_content_get_entry (ed->ifd[ifd], tag); + if (!e) { + fprintf (stderr, _("IFD '%s' does " + "not contain a tag '%s'!"), + exif_ifd_get_name (ifd), + exif_tag_get_name (tag)); + fputc ('\n', stderr); + return (1); + } + + exif_content_remove_entry (ed->ifd[ifd], e); } else action_tag_list (*args, ed, eo.use_ids); exif_data_unref (ed); |