Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

View File

@ -0,0 +1,85 @@
plugin_name = 'metadata-editor'
plugin_sources = [
'metadata-editor.c',
'metadata-impexp.c',
'metadata-tags.c',
'metadata-xml.c',
]
if platform_windows
plugin_rc = configure_file(
input : pika_plugins_rc.full_path(),
output: plugin_name + '.rc',
copy: true,
)
plugin_sources += windows.compile_resources(
plugin_rc,
args: [
'--define', 'ORIGINALFILENAME_STR="@0@"'.format(plugin_name+'.exe'),
'--define', 'INTERNALNAME_STR="@0@"' .format(plugin_name),
'--define', 'TOP_SRCDIR="@0@"' .format(meson.project_source_root()),
],
include_directories: [
rootInclude, appInclude,
],
)
endif
executable(plugin_name,
plugin_sources,
dependencies: [
libpikaui_dep,
gexiv2,
],
install: true,
install_dir: pikaplugindir / 'plug-ins' / plugin_name,
)
###############################################################################
plugin_name = 'metadata-viewer'
plugin_sources = [
'metadata-viewer.c',
'metadata-tags.c',
]
if platform_windows
plugin_rc = configure_file(
input : pika_plugins_rc.full_path(),
output: plugin_name + '.rc',
copy: true,
)
plugin_sources += windows.compile_resources(
plugin_rc,
args: [
'--define', 'ORIGINALFILENAME_STR="@0@"'.format(plugin_name+'.exe'),
'--define', 'INTERNALNAME_STR="@0@"' .format(plugin_name),
'--define', 'TOP_SRCDIR="@0@"' .format(meson.project_source_root()),
],
include_directories: [
rootInclude, appInclude,
],
)
endif
executable(plugin_name,
plugin_sources,
include_directories: [ rootInclude, ],
dependencies: [
gtk3, gegl, gexiv2,
],
link_with: [
libpika,
libpikabase,
libpikacolor,
libpikaconfig,
libpikamath,
libpikaui,
libpikawidgets,
],
install: true,
install_dir: pikaplugindir / 'plug-ins' / plugin_name,
)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2016, 2017 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __METADATA_EDITOR_H__
#define __METADATA_EDITOR_H__
void metadata_editor_write_callback (GtkWidget *dialog,
metadata_editor *meta_info,
PikaImage *image);
GtkWidget * metadata_editor_get_widget (metadata_editor *meta_info,
const gchar *name);
#endif /* __METADATA_EDITOR_H__ */

View File

@ -0,0 +1,261 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* metadata-editor.c
* Copyright (C) 2016, 2017 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gexiv2/gexiv2.h>
#include <glib/gstdio.h>
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "libpika/stdplugins-intl.h"
#include "metadata-xml.h"
#include "metadata-misc.h"
#include "metadata-tags.h"
#include "metadata-impexp.h"
#include "metadata-editor.h"
extern gboolean pikametadata;
extern gboolean xmptag;
extern gboolean iptctag;
extern gboolean tagvalue;
extern gboolean tagname;
extern gboolean force_write;
extern gchar *str_tag_value;
extern gchar *str_tag_name;
const GMarkupParser xml_markup_parser =
{
xml_parser_start_element,
xml_parser_end_element,
xml_parser_data,
NULL, /* passthrough */
NULL /* error */
};
typedef struct
{
MetadataMode mode;
gchar *mode_string;
} MetadataModeConversion;
const MetadataModeConversion metadata_mode_conversion[] =
{
{ MODE_SINGLE, "single" },
{ MODE_MULTI, "multi" },
{ MODE_COMBO, "combo" },
{ MODE_LIST, "list" },
};
/* ============================================================================
* ==[ METADATA IMPORT TEMPLATE ]==============================================
* ============================================================================
*/
void
import_file_metadata(metadata_editor *args)
{
PikaXmlParser *xml_parser;
GError *error = NULL;
FILE *file;
pikametadata = FALSE;
xmptag = FALSE;
iptctag = FALSE;
tagvalue = FALSE;
tagname = FALSE;
file = g_fopen (args->filename, "r");
if (file != NULL)
{
/* parse xml data fetched from file */
xml_parser = xml_parser_new (&xml_markup_parser, args);
if (! xml_parser_parse_file (xml_parser, args->filename, &error))
{
g_warning ("Error parsing xml: %s.", error? error->message: "");
g_clear_error (&error);
}
xml_parser_free (xml_parser);
fclose (file);
}
}
/* ============================================================================
* ==[ METADATA EXPORT TEMPLATE ]==============================================
* ============================================================================
*/
void
export_file_metadata (metadata_editor *args)
{
FILE *file;
GString *xmldata;
gint i, size;
if (force_write == TRUE)
{
/* Save fields in case of updates */
metadata_editor_write_callback (args->dialog, args, args->image);
/* Fetch a fresh copy of the metadata */
args->metadata = GEXIV2_METADATA (pika_image_get_metadata (args->image));
}
xmldata = g_string_new ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<pika-metadata>\n");
/* HANDLE IPTC */
for (i = 0; i < n_equivalent_metadata_tags; i++)
{
int index = equivalent_metadata_tags[i].default_tag_index;
g_string_append (xmldata, "\t<iptc-tag>\n");
g_string_append (xmldata, "\t\t<tag-name>");
g_string_append (xmldata, equivalent_metadata_tags[i].tag);
g_string_append (xmldata, "</tag-name>\n");
g_string_append (xmldata, "\t\t<tag-mode>");
g_string_append (xmldata, metadata_mode_conversion[equivalent_metadata_tags[i].mode].mode_string);
g_string_append (xmldata, "</tag-mode>\n");
g_string_append (xmldata, "\t\t<tag-value>");
if (default_metadata_tags[index].mode == MODE_SINGLE ||
default_metadata_tags[index].mode == MODE_MULTI)
{
const gchar *value;
value = get_tag_ui_text (args, default_metadata_tags[index].tag,
default_metadata_tags[index].mode);
if (value)
{
gchar *value_utf;
value_utf = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
g_string_append (xmldata, value_utf);
g_free (value_utf);
}
}
else if (default_metadata_tags[index].mode == MODE_COMBO)
{
gint data = get_tag_ui_combo (args, default_metadata_tags[index].tag,
default_metadata_tags[index].mode);
g_string_append_printf (xmldata, "%d", data);
}
else if (default_metadata_tags[i].mode == MODE_LIST)
{
/* No IPTC lists elements at this point */
}
g_string_append (xmldata, "</tag-value>\n");
g_string_append (xmldata, "\t</iptc-tag>\n");
}
/* HANDLE XMP */
for (i = 0; i < n_default_metadata_tags; i++)
{
g_string_append (xmldata, "\t<xmp-tag>\n");
g_string_append (xmldata, "\t\t<tag-name>");
g_string_append (xmldata, default_metadata_tags[i].tag);
g_string_append (xmldata, "</tag-name>\n");
g_string_append (xmldata, "\t\t<tag-mode>");
g_string_append (xmldata, metadata_mode_conversion[default_metadata_tags[i].mode].mode_string);
g_string_append (xmldata, "</tag-mode>\n");
if (default_metadata_tags[i].mode == MODE_SINGLE ||
default_metadata_tags[i].mode == MODE_MULTI)
{
const gchar *value;
g_string_append (xmldata, "\t\t<tag-value>");
value = get_tag_ui_text (args, default_metadata_tags[i].tag,
default_metadata_tags[i].mode);
if (value)
{
gchar *value_utf;
value_utf = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
g_string_append (xmldata, value_utf);
g_free (value_utf);
}
g_string_append (xmldata, "</tag-value>\n");
}
else if (default_metadata_tags[i].mode == MODE_COMBO)
{
gint data;
g_string_append (xmldata, "\t\t<tag-value>");
data = get_tag_ui_combo (args, default_metadata_tags[i].tag,
default_metadata_tags[i].mode);
g_string_append_printf (xmldata, "%d", data);
g_string_append (xmldata, "</tag-value>\n");
}
else if (default_metadata_tags[i].mode == MODE_LIST)
{
gchar *data;
g_string_append (xmldata, "\t\t<tag-list-value>\n");
data = get_tag_ui_list (args, default_metadata_tags[i].tag,
default_metadata_tags[i].mode);
if (data)
{
g_string_append (xmldata, data);
g_free(data);
}
g_string_append (xmldata, "\t\t</tag-list-value>\n");
}
g_string_append (xmldata, "\t</xmp-tag>\n");
}
g_string_append (xmldata, "</pika-metadata>\n");
size = strlen (xmldata->str);
file = g_fopen (args->filename, "w");
if (file != NULL)
{
GError *error = NULL;
if (! g_file_set_contents (args->filename, xmldata->str, size, &error))
{
g_warning ("Error saving file: %s.", error? error->message: "");
g_clear_error (&error);
}
fclose (file);
}
if (xmldata)
{
g_string_free(xmldata, TRUE);
}
}

View File

@ -0,0 +1,31 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2016, 2017 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __METADATA_IMPEXP_H__
#define __METADATA_IMPEXP_H__
void import_file_metadata (metadata_editor *args);
void export_file_metadata (metadata_editor *args);
#endif /* __METADATA_IMPEXP_H__ */

View File

@ -0,0 +1,90 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2016, 2017 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __METADATA_MISC_H__
#define __METADATA_MISC_H__
typedef struct
{
GtkWidget *dialog;
GHashTable *widgets;
GExiv2Metadata *metadata;
PikaImage *image;
gchar *filename;
} metadata_editor;
typedef enum
{
MODE_SINGLE,
MODE_MULTI,
MODE_COMBO,
MODE_LIST,
} MetadataMode;
typedef struct
{
gchar *tag;
MetadataMode mode;
gint32 other_tag_index;
gint32 tag_type;
gint32 xmp_type;
} metadata_tag;
typedef struct
{
gchar *tag;
MetadataMode mode;
gint32 default_tag_index;
gint32 exif_tag_index;
} iptc_tag_info;
typedef struct
{
gint32 xmp_equivalent_index;
gchar *tag;
MetadataMode mode;
} exif_tag_info;
typedef struct
{
gchar *data;
gchar *display;
} combobox_str_tag;
typedef struct
{
gint32 data;
gchar *display;
} combobox_int_tag;
typedef struct
{
gchar *id;
gchar *tag;
MetadataMode mode;
gint32 other_tag_index;
gint32 tag_type;
} TranslateTag;
#endif /* __METADATA_MISC_H__ */

View File

@ -0,0 +1,514 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gexiv2/gexiv2.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <libpika/pika.h>
#include "libpika/stdplugins-intl.h"
#include "metadata-tags.h"
/* The meaning of MODE_SINGLE and MODE_MULTI here denotes whether it is used
* in a single line or a multi line edit field.
* Depending on it's xmp type multi line can be saved as either:
* - one tag of type text, possibly including newlines
* - an array of tags of the same type for seq and bag, where each line in
* the multi line edit will be one item in the array
*/
const metadata_tag default_metadata_tags[] =
{
/* Description */
{ "Xmp.dc.title", MODE_SINGLE, 16, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 0
{ "Xmp.dc.creator", MODE_MULTI, 13, TAG_TYPE_XMP, PIKA_XMP_SEQ }, // 1
{ "Xmp.dc.description", MODE_MULTI, 14, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 2
{ "Xmp.dc.subject", MODE_MULTI, 15, TAG_TYPE_XMP, PIKA_XMP_BAG }, // 3
{ "Xmp.dc.rights", MODE_SINGLE, 17, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 4
{ "Xmp.photoshop.AuthorsPosition", MODE_SINGLE, 19, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 5
{ "Xmp.photoshop.CaptionWriter", MODE_SINGLE, 21, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 6
{ "Xmp.xmp.Rating", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 7
{ "Xmp.xmpRights.Marked", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 8
{ "Xmp.xmpRights.WebStatement", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 9
/* IPTC */
{ "Xmp.photoshop.DateCreated", MODE_SINGLE, 0, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 10
{ "Xmp.photoshop.Headline", MODE_MULTI, 3, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 11
{ "Xmp.photoshop.TransmissionReference", MODE_SINGLE, 1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 12
{ "Xmp.photoshop.Instructions", MODE_MULTI, 2, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 13
{ "Xmp.iptc.IntellectualGenre", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 14
{ "Xmp.iptc.Scene", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_BAG }, // 15
{ "Xmp.iptc.Location", MODE_SINGLE, 18, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 16
{ "Xmp.iptc.CountryCode", MODE_SINGLE, 20, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 17
{ "Xmp.iptc.SubjectCode", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_BAG }, // 18
{ "Xmp.xmpRights.UsageTerms", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 19
{ "Xmp.photoshop.City", MODE_SINGLE, 5, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 20
{ "Xmp.photoshop.State", MODE_SINGLE, 6, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 21
{ "Xmp.photoshop.Country", MODE_SINGLE, 7, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 22
/* Xmp.photoshop.CaptionWriter here is a duplicate of #6 above. We keep it here to not have
* to renumber the tag references. It seems it is not used on the IPTC tab. */
{ "Xmp.photoshop.CaptionWriter", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 23
{ "Xmp.photoshop.Credit", MODE_SINGLE, 8, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 24
{ "Xmp.photoshop.Source", MODE_SINGLE, 9, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 25
{ "Xmp.photoshop.Urgency", MODE_COMBO, 11, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 26
/* IPTC Extension */
{ "Xmp.iptcExt.PersonInImage", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_BAG }, // 27
{ "Xmp.iptcExt.Sublocation", MODE_SINGLE, 12, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 28
{ "Xmp.iptcExt.City", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 29
{ "Xmp.iptcExt.ProvinceState", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 30
{ "Xmp.iptcExt.CountryName", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 31
{ "Xmp.iptcExt.CountryCode", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 32
{ "Xmp.iptcExt.WorldRegion", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 33
{ "Xmp.iptcExt.LocationShown", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 34
{ "Xmp.iptcExt.OrganisationInImageName", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 35
{ "Xmp.iptcExt.OrganisationInImageCode", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 36
{ "Xmp.iptcExt.Event", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 37
{ "Xmp.iptcExt.RegistryId", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 38
{ "Xmp.iptcExt.ArtworkOrObject", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 39
{ "Xmp.iptcExt.AddlModelInfo", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 40
{ "Xmp.iptcExt.ModelAge", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_BAG }, // 41
{ "Xmp.iptcExt.MaxAvailWidth", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 42
{ "Xmp.iptcExt.MaxAvailHeight", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 43
{ "Xmp.iptcExt.DigitalSourceType", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 44
{ "Xmp.plus.MinorModelAgeDisclosure", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 45
{ "Xmp.plus.ModelReleaseStatus", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 46
{ "Xmp.plus.ModelReleaseID", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 47
{ "Xmp.plus.ImageSupplierName", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 48
{ "Xmp.plus.ImageSupplierID", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 49
{ "Xmp.plus.ImageSupplierImageID", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 50
{ "Xmp.plus.ImageCreator", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 51
{ "Xmp.plus.CopyrightOwner", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 52
{ "Xmp.plus.Licensor", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 53
{ "Xmp.plus.PropertyReleaseStatus", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 54
{ "Xmp.plus.PropertyReleaseID", MODE_LIST, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 55
/* Categories */
{ "Xmp.photoshop.Category", MODE_SINGLE, 4, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 56
{ "Xmp.photoshop.SupplementalCategories", MODE_MULTI, 10, TAG_TYPE_XMP, PIKA_XMP_BAG }, // 57
/* GPS */
{ "Exif.GPSInfo.GPSLongitude", MODE_SINGLE, -1, TAG_TYPE_EXIF, PIKA_XMP_NONE }, // 58
{ "Exif.GPSInfo.GPSLongitudeRef", MODE_COMBO, -1, TAG_TYPE_EXIF, PIKA_XMP_NONE }, // 59
{ "Exif.GPSInfo.GPSLatitude", MODE_SINGLE, -1, TAG_TYPE_EXIF, PIKA_XMP_NONE }, // 60
{ "Exif.GPSInfo.GPSLatitudeRef", MODE_COMBO, -1, TAG_TYPE_EXIF, PIKA_XMP_NONE }, // 61
{ "Exif.GPSInfo.GPSAltitude", MODE_SINGLE, -1, TAG_TYPE_EXIF, PIKA_XMP_NONE }, // 62
{ "Exif.GPSInfo.GPSAltitudeRef", MODE_COMBO, -1, TAG_TYPE_EXIF, PIKA_XMP_NONE }, // 63
/* DICOM */
{ "Xmp.DICOM.PatientName", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 64
{ "Xmp.DICOM.PatientID", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 65
{ "Xmp.DICOM.PatientDOB", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 66
{ "Xmp.DICOM.PatientSex", MODE_COMBO, -1, TAG_TYPE_XMP, PIKA_XMP_NONE }, // 67
{ "Xmp.DICOM.StudyID", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 68
{ "Xmp.DICOM.StudyPhysician", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 69
{ "Xmp.DICOM.StudyDateTime", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 70
{ "Xmp.DICOM.StudyDescription", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 71
{ "Xmp.DICOM.SeriesNumber", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 72
{ "Xmp.DICOM.SeriesModality", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 73
{ "Xmp.DICOM.SeriesDateTime", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 74
{ "Xmp.DICOM.SeriesDescription", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 75
{ "Xmp.DICOM.EquipmentInstitution", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 76
{ "Xmp.DICOM.EquipmentManufacturer", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 77
/* IPTC */
{ "Xmp.iptc.CiAdrExtadr", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 78
{ "Xmp.iptc.CiAdrCity", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 79
{ "Xmp.iptc.CiAdrRegion", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 80
{ "Xmp.iptc.CiAdrPcode", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 81
{ "Xmp.iptc.CiAdrCtry", MODE_SINGLE, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 82
{ "Xmp.iptc.CiTelWork", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 83
{ "Xmp.iptc.CiEmailWork", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT }, // 84
{ "Xmp.iptc.CiUrlWork", MODE_MULTI, -1, TAG_TYPE_XMP, PIKA_XMP_TEXT } // 85
};
const gint n_default_metadata_tags = G_N_ELEMENTS (default_metadata_tags);
/* Then meaning of MODE_SINGLE and MODE_MULTI below is a little different than above.
* MODE_SINGLE - for iptc tags that can appear only once,
* MODE_MULTI - for iptc tags that are repeatable, i.e. can appear multiple times.
*/
const iptc_tag_info equivalent_metadata_tags[] =
{
{ "Iptc.Application2.DateCreated", MODE_SINGLE, 10, -1 }, // 0
{ "Iptc.Application2.TransmissionReference", MODE_SINGLE, 12, -1 }, // 1
{ "Iptc.Application2.SpecialInstructions", MODE_SINGLE, 13, -1 }, // 2
{ "Iptc.Application2.Headline", MODE_SINGLE, 11, -1 }, // 3
{ "Iptc.Application2.Category", MODE_SINGLE, 56, -1 }, // 4
{ "Iptc.Application2.City", MODE_SINGLE, 20, -1 }, // 5
{ "Iptc.Application2.ProvinceState", MODE_SINGLE, 21, -1 }, // 6
{ "Iptc.Application2.CountryName", MODE_SINGLE, 22, -1 }, // 7
{ "Iptc.Application2.Credit", MODE_SINGLE, 24, -1 }, // 8
{ "Iptc.Application2.Source", MODE_SINGLE, 25, -1 }, // 9
{ "Iptc.Application2.SuppCategory", MODE_MULTI, 57, -1 }, // 10
{ "Iptc.Application2.Urgency", MODE_COMBO, 26, -1 }, // 11
{ "Iptc.Application2.SubLocation", MODE_SINGLE, 28, -1 }, // 12
{ "Iptc.Application2.Byline", MODE_SINGLE, 1, 0 }, // 13
{ "Iptc.Application2.Caption", MODE_SINGLE, 2, 1 }, // 14
{ "Iptc.Application2.Keywords", MODE_MULTI, 3, -1 }, // 15
{ "Iptc.Application2.ObjectName", MODE_SINGLE, 0, -1 }, // 16
{ "Iptc.Application2.Copyright", MODE_SINGLE, 4, 2 }, // 17
{ "Iptc.Application2.LocationName", MODE_MULTI, 16, -1 }, // 18
{ "Iptc.Application2.BylineTitle", MODE_MULTI, 5, -1 }, // 19
{ "Iptc.Application2.CountryCode", MODE_SINGLE, 17, -1 }, // 20
{ "Iptc.Application2.Writer", MODE_MULTI, 6, -1 }, // 21
};
const gint n_equivalent_metadata_tags = G_N_ELEMENTS (equivalent_metadata_tags);
const exif_tag_info exif_equivalent_tags[] =
{
{ 1, "Exif.Image.Artist", MODE_SINGLE}, // 0
{ 2, "Exif.Image.ImageDescription", MODE_SINGLE}, // 1
{ 4, "Exif.Image.Copyright", MODE_SINGLE}, // 2
};
/* Digital Source Type Combobox Items
* http://cv.iptc.org/newscodes/digitalsourcetype/
*/
const combobox_str_tag digitalsourcetype[] =
{
{ "", N_("Select a value") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture", N_("Original digital capture of a real life scene") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/negativeFilm", N_("Digitized from a negative on film") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/positiveFilm", N_("Digitized from a positive on film") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/print", N_("Digitized from a print on non-transparent medium") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/minorHumanEdits", N_("Original media with minor human edits") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/compositeCapture", N_("Composite of captured elements") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicallyEnhanced", N_("Algorithmically-enhanced media") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/dataDrivenMedia", N_("Data-driven media") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/digitalArt", N_("Digital art") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/virtualRecording", N_("Virtual recording") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/compositeSynthetic", N_("Composite including synthetic elements") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia", N_("Trained algorithmic media") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/algorithmicMedia", N_("Pure algorithmic media") },
{ "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage", N_("Created by software") }
};
const gint n_digitalsourcetype = G_N_ELEMENTS (digitalsourcetype);
/* Model Release Status Combobox Items
* http://ns.useplus.org/LDF/ldf-XMPSpecification#ModelReleaseStatus
*/
const combobox_str_tag modelreleasestatus[] =
{
{ "", N_("Select a value") },
{ "http://ns.useplus.org/ldf/vocab/MR-NON", N_("None") },
{ "http://ns.useplus.org/ldf/vocab/MR-NAP", N_("Not Applicable") },
{ "http://ns.useplus.org/ldf/vocab/MR-UMR", N_("Unlimited Model Releases") },
{ "http://ns.useplus.org/ldf/vocab/MR-LMR", N_("Limited or Incomplete Model Releases") }
};
const gint n_modelreleasestatus = G_N_ELEMENTS (modelreleasestatus);
/* Property Release Status Combobox Items
* http://ns.useplus.org/LDF/ldf-XMPSpecification#PropertyReleaseStatus
*/
const combobox_str_tag propertyreleasestatus[] =
{
{ "http://ns.useplus.org/ldf/vocab/PR-NON", N_("None") },
{ "http://ns.useplus.org/ldf/vocab/PR-NAP", N_("Not Applicable") },
{ "http://ns.useplus.org/ldf/vocab/PR-UPR", N_("Unlimited Property Releases") },
{ "http://ns.useplus.org/ldf/vocab/PR-LPR", N_("Limited or Incomplete Property Releases") }
};
const gint n_propertyreleasestatus = G_N_ELEMENTS (propertyreleasestatus);
/* Minor Model Age Disclosure Combobox Items
* http://ns.useplus.org/LDF/ldf-XMPSpecification#MinorModelAgeDisclosure
*/
const combobox_str_tag minormodelagedisclosure[] =
{
{ "http://ns.useplus.org/ldf/vocab/AG-UNK", N_("Age Unknown") },
{ "http://ns.useplus.org/ldf/vocab/AG-A25", N_("Age 25 or Over") },
{ "http://ns.useplus.org/ldf/vocab/AG-A24", N_("Age 24") },
{ "http://ns.useplus.org/ldf/vocab/AG-A23", N_("Age 23") },
{ "http://ns.useplus.org/ldf/vocab/AG-A22", N_("Age 22") },
{ "http://ns.useplus.org/ldf/vocab/AG-A21", N_("Age 21") },
{ "http://ns.useplus.org/ldf/vocab/AG-A20", N_("Age 20") },
{ "http://ns.useplus.org/ldf/vocab/AG-A19", N_("Age 19") },
{ "http://ns.useplus.org/ldf/vocab/AG-A18", N_("Age 18") },
{ "http://ns.useplus.org/ldf/vocab/AG-A17", N_("Age 17") },
{ "http://ns.useplus.org/ldf/vocab/AG-A16", N_("Age 16") },
{ "http://ns.useplus.org/ldf/vocab/AG-A15", N_("Age 15") },
{ "http://ns.useplus.org/ldf/vocab/AG-U14", N_("Age 14 or Under") }
};
const gint n_minormodelagedisclosure = G_N_ELEMENTS (minormodelagedisclosure);
/* Urgency */
const gchar *urgency[] =
{
N_("None"), N_("High"), N_("2"), N_("3"), N_("4"), N_("Normal"), N_("6"), N_("7"), N_("Low")
};
const gint n_urgency = G_N_ELEMENTS (urgency);
/* Marked */
const combobox_int_tag marked[] =
{
{ -1, N_("Unknown") }, // DO NOT SAVE
{ TRUE, N_("Copyrighted") }, // TRUE
{ FALSE, N_("Public Domain") }, // FALSE
};
const gint n_marked = G_N_ELEMENTS (marked);
/* Phone Types */
const combobox_str_tag phone_types[] =
{
{ "", N_("Select a value") },
{ "http://ns.useplus.org/ldf/vocab/work", N_("Work") },
{ "http://ns.useplus.org/ldf/vocab/cell", N_("Cell") },
{ "http://ns.useplus.org/ldf/vocab/fax", N_("Fax") },
{ "http://ns.useplus.org/ldf/vocab/home", N_("Home") },
{ "http://ns.useplus.org/ldf/vocab/pager", N_("Pager") }
};
const gint n_phone_types = G_N_ELEMENTS (phone_types);
/* DICOM Patient Sex
* http://dicomlookup.com/lookup.asp?sw=Ttable&q=C.7-1
* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/XMP.html#DICOM
* https://dicomiseasy.blogspot.ca/2011/11/introduction-to-dicom-chapter-iii-dicom.html
* http://dicom.nema.org/standard.html
*/
const combobox_str_tag dicom[] =
{
{ "", N_("Select a value") },
{ "male", N_("Male") },
{ "female", N_("Female") },
{ "other", N_("Other") },
};
const gint n_dicom = G_N_ELEMENTS (dicom);
/* GPS Altitude Ref */
const gchar *gpsaltref[] =
{
N_("Unknown"), N_("Above sea level"), N_("Below sea level")
};
const gint n_gpsaltref = G_N_ELEMENTS (gpsaltref);
/* GPS Latitude Ref */
const gchar *gpslatref[] =
{
N_("Unknown"), N_("North"), N_("South")
};
const gint n_gpslatref = G_N_ELEMENTS (gpslatref);
/* GPS Longitude Ref */
const gchar *gpslngref[] =
{
N_("Unknown"), N_("East"), N_("West")
};
const gint n_gpslngref = G_N_ELEMENTS (gpslngref);
/* GPS Measurement System */
const gchar *gpsaltsys[] =
{
"m", "ft"
};
const gint n_gpsaltsys = G_N_ELEMENTS (gpsaltsys);
const TranslateTag creatorContactInfoTags[] =
{
{ "Xmp.iptc.CiAdrExtadr", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrExtadr", MODE_MULTI, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiAdrCity", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiAdrRegion", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrRegion", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiAdrPcode", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrPcode", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiAdrCtry", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiTelWork", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiTelWork", MODE_MULTI, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiEmailWork", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiEmailWork", MODE_MULTI, -1, TAG_TYPE_XMP },
{ "Xmp.iptc.CiUrlWork", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork", MODE_MULTI, -1, TAG_TYPE_XMP }
};
const gint n_creatorContactInfoTags = G_N_ELEMENTS (creatorContactInfoTags);
const TranslateTag locationCreationInfoTags[] =
{
{ "Xmp.iptcExt.Sublocation", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:Sublocation", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptcExt.City", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:City", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptcExt.ProvinceState", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:ProvinceState", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptcExt.CountryName", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:CountryName", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptcExt.CountryCode", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:CountryCode", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.iptcExt.WorldRegion", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:WorldRegion", MODE_SINGLE, -1, TAG_TYPE_XMP }
};
const gint n_locationCreationInfoTags = G_N_ELEMENTS (locationCreationInfoTags);
const TranslateTag imageSupplierInfoTags[] =
{
{ "Xmp.plus.ImageSupplierName", "Xmp.plus.ImageSupplier[1]/plus:ImageSupplierName", MODE_SINGLE, -1, TAG_TYPE_XMP },
{ "Xmp.plus.ImageSupplierID", "Xmp.plus.ImageSupplier[1]/plus:ImageSupplierID", MODE_SINGLE, -1, TAG_TYPE_XMP }
};
const gint n_imageSupplierInfoTags = G_N_ELEMENTS (imageSupplierInfoTags);
/* Plus and IPTC extension tags */
const gchar *licensor[] =
{
"/plus:LicensorName",
"/plus:LicensorID",
"/plus:LicensorTelephone1",
"/plus:LicensorTelephoneType1",
"/plus:LicensorTelephone2",
"/plus:LicensorTelephoneType2",
"/plus:LicensorEmail",
"/plus:LicensorURL"
};
const gint n_licensor = G_N_ELEMENTS (licensor);
const gint licensor_special_handling[] =
{
METADATA_NONE,
METADATA_NONE,
METADATA_NONE,
METADATA_PHONETYPE,
METADATA_NONE,
METADATA_PHONETYPE,
METADATA_NONE,
METADATA_NONE
};
#ifdef USE_TAGS
const gchar *imagesupplier[] =
{
"/plus:ImageSupplierName",
"/plus:ImageSupplierID"
};
const gint n_imagesupplier = G_N_ELEMENTS (imagesupplier);
#endif
const gchar *imagecreator[] =
{
"/plus:ImageCreatorName",
"/plus:ImageCreatorID"
};
const gint n_imagecreator = G_N_ELEMENTS (imagecreator);
const gchar *copyrightowner[] =
{
"/plus:CopyrightOwnerName",
"/plus:CopyrightOwnerID"
};
const gint n_copyrightowner = G_N_ELEMENTS (copyrightowner);
const gchar *registryid[] =
{
"/Iptc4xmpExt:RegOrgId",
"/Iptc4xmpExt:RegItemId"
};
const gint n_registryid = G_N_ELEMENTS (registryid);
const gchar *registryid_alternative[] =
{
"/iptcExt:RegOrgId",
"/iptcExt:RegItemId"
};
const gchar *artworkorobject[] =
{
"/Iptc4xmpExt:AOTitle",
"/Iptc4xmpExt:AODateCreated",
"/Iptc4xmpExt:AOCreator",
"/Iptc4xmpExt:AOSource",
"/Iptc4xmpExt:AOSourceInvNo",
"/Iptc4xmpExt:AOCopyrightNotice",
};
const gint n_artworkorobject = G_N_ELEMENTS (artworkorobject);
const gchar *artworkorobject_alternative[] =
{
"/iptcExt:AOTitle",
"/iptcExt:AODateCreated",
"/iptcExt:AOCreator",
"/iptcExt:AOSource",
"/iptcExt:AOSourceInvNo",
"/iptcExt:AOCopyrightNotice",
};
const gchar *locationshown[] =
{
"/Iptc4xmpExt:Sublocation",
"/Iptc4xmpExt:City",
"/Iptc4xmpExt:ProvinceState",
"/Iptc4xmpExt:CountryName",
"/Iptc4xmpExt:CountryCode",
"/Iptc4xmpExt:WorldRegion"
};
const gint n_locationshown = G_N_ELEMENTS (locationshown);
const gchar *locationshown_alternative[] =
{
"/iptcExt:Sublocation",
"/iptcExt:City",
"/iptcExt:ProvinceState",
"/iptcExt:CountryName",
"/iptcExt:CountryCode",
"/iptcExt:WorldRegion"
};
#ifdef USE_TAGS
const gchar *locationcreated[] =
{
"/Iptc4xmpExt:Sublocation",
"/Iptc4xmpExt:City",
"/Iptc4xmpExt:ProvinceState",
"/Iptc4xmpExt:CountryName",
"/Iptc4xmpExt:CountryCode",
"/Iptc4xmpExt:WorldRegion"
};
const gint n_locationcreated = G_N_ELEMENTS (locationcreated);
#endif
gchar *
metadata_format_gps_longitude_latitude (const gdouble value)
{
gint deg, min;
gdouble sec;
gdouble gps_value = value;
if (gps_value < 0.f)
gps_value *= -1.f;
deg = (gint) gps_value;
min = (gint) ((gps_value - (gdouble) deg) * 60.f);
sec = ((gps_value - (gdouble) deg - (gdouble) (min / 60.f)) * 60.f * 60.f);
return g_strdup_printf ("%ddeg %d' %.3f\"", deg, min, sec);
}
/*
* use_meter: True return meters, False return feet
* measurement_symbol: Should be "m", "ft", or empty string (not NULL)
*/
gchar *
metadata_format_gps_altitude (const gdouble value,
gboolean use_meter,
gchar *measurement_symbol)
{
gdouble gps_value = value;
if (gps_value < 0.f)
gps_value *= -1.f;
if (! use_meter)
{
gps_value *= 3.28;
}
return g_strdup_printf ("%.2f%s", gps_value, measurement_symbol);
}

View File

@ -0,0 +1,259 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2016, 2017 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __METADATA_TAGS_H__
#define __METADATA_TAGS_H__
#include "metadata-misc.h"
#define TAG_TYPE_XMP 1
#define TAG_TYPE_EXIF 2
#define TAG_TYPE_IPTC 3
enum
{
PIKA_XMP_NONE = 0,
PIKA_XMP_TEXT,
PIKA_XMP_BAG,
PIKA_XMP_SEQ,
PIKA_XMP_LANG,
PIKA_XMP_ALT
};
enum
{
COL_LICENSOR_NAME = 0,
COL_LICENSOR_ID,
COL_LICENSOR_PHONE1,
COL_LICENSOR_PHONE_TYPE1,
COL_LICENSOR_PHONE2,
COL_LICENSOR_PHONE_TYPE2,
COL_LICENSOR_EMAIL,
COL_LICENSOR_WEB,
COL_LICENSOR_NUM_COLS
};
enum
{
COL_CR_OWNER_NAME = 0,
COL_CR_OWNER_ID,
COL_CR_OWNER_NUM_COLS
};
enum
{
COL_IMG_CR8_NAME = 0,
COL_IMG_CR8_ID,
COL_IMG_CR8_NUM_COLS
};
enum
{
COL_AOO_TITLE = 0,
COL_AOO_DATE_CREAT,
COL_AOO_CREATOR,
COL_AOO_SOURCE,
COL_AOO_SRC_INV_ID,
COL_AOO_CR_NOT,
COL_AOO_NUM_COLS
};
enum
{
COL_REGISTRY_ORG_ID = 0,
COL_REGISTRY_ITEM_ID,
COL_REGISTRY_NUM_COLS
};
enum
{
COL_LOC_SHO_SUB_LOC = 0,
COL_LOC_SHO_CITY,
COL_LOC_SHO_STATE_PROV,
COL_LOC_SHO_CNTRY,
COL_LOC_SHO_CNTRY_ISO,
COL_LOC_SHO_CNTRY_WRLD_REG,
COL_LOC_SHO_NUM_COLS
};
enum
{
COL_ORG_IMG_CODE = 0,
ORG_IMG_CODE_REL_NUM_COLS
};
enum
{
COL_ORG_IMG_NAME = 0,
ORG_IMG_NAME_REL_NUM_COLS
};
enum
{
COL_MOD_REL_ID = 0,
MOD_REL_NUM_COLS
};
enum
{
COL_PROP_REL_ID = 0,
PROP_REL_NUM_COLS
};
enum METADATA_SPECIAL_PROCESSING
{
METADATA_NONE = 0,
METADATA_PHONETYPE,
METADATA_PREPROCESS_TEXT
};
extern const metadata_tag default_metadata_tags[];
extern const gint n_default_metadata_tags;
extern const iptc_tag_info equivalent_metadata_tags[];
extern const gint n_equivalent_metadata_tags;
extern const exif_tag_info exif_equivalent_tags[];
/* Tag indexes in equivalent_metadata_tags that need special processing. */
#define SPECIAL_PROCESSING_DATE_CREATED 0
/* Digital Source Type Combobox Items
* http://cv.iptc.org/newscodes/digitalsourcetype/
*/
extern const combobox_str_tag digitalsourcetype[];
extern const gint n_digitalsourcetype;
/* Model Release Status Combobox Items
* http://ns.useplus.org/LDF/ldf-XMPSpecification#ModelReleaseStatus
*/
extern const combobox_str_tag modelreleasestatus[];
extern const gint n_modelreleasestatus;
/* Property Release Status Combobox Items
* http://ns.useplus.org/LDF/ldf-XMPSpecification#PropertyReleaseStatus
*/
extern const combobox_str_tag propertyreleasestatus[];
extern const gint n_propertyreleasestatus;
/* Minor Model Age Disclosure Combobox Items
* http://ns.useplus.org/LDF/ldf-XMPSpecification#MinorModelAgeDisclosure
*/
extern const combobox_str_tag minormodelagedisclosure[];
extern const gint n_minormodelagedisclosure;
/* Urgency */
extern const gchar *urgency[];
extern const gint n_urgency;
/* Marked */
extern const combobox_int_tag marked[];
extern const gint n_marked;
/* Phone Types */
extern const combobox_str_tag phone_types[];
extern const gint n_phone_types;
/* DICOM Patient Sex
* http://dicomlookup.com/lookup.asp?sw=Ttable&q=C.7-1
* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/XMP.html#DICOM
* https://dicomiseasy.blogspot.ca/2011/11/introduction-to-dicom-chapter-iii-dicom.html
* http://dicom.nema.org/standard.html
*/
extern const combobox_str_tag dicom[];
extern const gint n_dicom;
/* GPS Altitude Ref */
extern const gchar *gpsaltref[];
extern const gint n_gpsaltref;
/* GPS Latitude Ref */
extern const gchar *gpslatref[];
extern const gint n_gpslatref;
/* GPS Longitude Ref */
extern const gchar *gpslngref[];
extern const gint n_gpslngref;
/* GPS Measurement System */
extern const gchar *gpsaltsys[];
extern const gint n_gpsaltsys;
extern const TranslateTag creatorContactInfoTags[];
extern const gint n_creatorContactInfoTags;
extern const TranslateTag locationCreationInfoTags[];
extern const gint n_locationCreationInfoTags;
extern const TranslateTag imageSupplierInfoTags[];
extern const gint n_imageSupplierInfoTags;
/* Plus and IPTC extension tags */
#define LICENSOR_HEADER "Xmp.plus.Licensor"
extern const gchar *licensor[];
extern const gint n_licensor;
extern const gint licensor_special_handling[];
#ifdef USE_TAGS
#define IMAGESUPPLIER_HEADER "Xmp.plus.ImageSupplier"
extern const gchar *imagesupplier[];
extern const gint n_imagesupplier;
#endif
#define IMAGECREATOR_HEADER "Xmp.plus.ImageCreator"
extern const gchar *imagecreator[];
extern const gint n_imagecreator;
#define COPYRIGHTOWNER_HEADER "Xmp.plus.CopyrightOwner"
extern const gchar *copyrightowner[];
extern const gint n_copyrightowner;
#define REGISTRYID_HEADER "Xmp.iptcExt.RegistryId"
extern const gchar *registryid[];
extern const gchar *registryid_alternative[];
extern const gint n_registryid;
#define ARTWORKOROBJECT_HEADER "Xmp.iptcExt.ArtworkOrObject"
extern const gchar *artworkorobject[];
extern const gchar *artworkorobject_alternative[];
extern const gint n_artworkorobject;
#define LOCATIONSHOWN_HEADER "Xmp.iptcExt.LocationShown"
extern const gchar *locationshown[];
extern const gchar *locationshown_alternative[];
extern const gint n_locationshown;
#ifdef USE_TAGS
#define LOCATIONCREATED_HEADER "Xmp.iptcExt.LocationCreated"
extern const gchar *locationcreated[];
extern const gint n_locationcreated;
#endif
gchar * metadata_format_gps_longitude_latitude (const gdouble value);
gchar * metadata_format_gps_altitude (const gdouble value,
gboolean use_meter,
gchar *measurement_symbol);
#endif /* __METADATA_TAGS_H__ */

View File

@ -0,0 +1,911 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* metadata.c
* Copyright (C) 2013 Hartmut Kuhse
* Copyright (C) 2016 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gexiv2/gexiv2.h>
#include <libpika/pika.h>
#include <libpika/pikaui.h>
#include "libpika/stdplugins-intl.h"
#include "metadata-tags.h"
#define PLUG_IN_PROC "plug-in-metadata-viewer"
#define PLUG_IN_BINARY "metadata-viewer"
#define PLUG_IN_ROLE "pika-metadata"
#define EXIF_PREFIX "Exif."
#define IPTC_PREFIX "Iptc."
#define XMP_PREFIX "Xmp."
/* The length at which to truncate tag values, in characters. */
#define TAG_VALUE_MAX_SIZE 1024
/* The length at which to truncate raw data (i.e., tag values
* of type "Byte" or "Undefined"), in bytes.
*/
#define RAW_DATA_MAX_SIZE 16
enum
{
C_XMP_TAG = 0,
C_XMP_VALUE,
NUM_XMP_COLS
};
enum
{
C_EXIF_TAG = 0,
C_EXIF_VALUE,
NUM_EXIF_COLS
};
enum
{
C_IPTC_TAG = 0,
C_IPTC_VALUE,
NUM_IPTC_COLS
};
typedef struct _Metadata Metadata;
typedef struct _MetadataClass MetadataClass;
struct _Metadata
{
PikaPlugIn parent_instance;
};
struct _MetadataClass
{
PikaPlugInClass parent_class;
};
#define METADATA_TYPE (metadata_get_type ())
#define METADATA (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), METADATA_TYPE, Metadata))
GType metadata_get_type (void) G_GNUC_CONST;
static GList * metadata_query_procedures (PikaPlugIn *plug_in);
static PikaProcedure * metadata_create_procedure (PikaPlugIn *plug_in,
const gchar *name);
static PikaValueArray * metadata_run (PikaProcedure *procedure,
const PikaValueArray *args,
gpointer run_data);
static gboolean metadata_viewer_dialog (PikaImage *image,
PikaMetadata *g_metadata,
GError **error);
static void metadata_dialog_set_metadata (GExiv2Metadata *metadata,
GtkListStore *exif_store,
GtkListStore *xmp_store,
GtkListStore *iptc_store);
static void metadata_dialog_add_multiple_values (GExiv2Metadata *metadata,
const gchar *tag,
GtkListStore *store,
gint tag_column,
gint value_column);
static void metadata_dialog_append_tags (GExiv2Metadata *metadata,
gchar **tags,
GtkListStore *store,
gint tag_column,
gint value_column,
gboolean load_iptc);
static void metadata_dialog_add_tag (GtkListStore *store,
gint tag_column,
gint value_column,
const gchar *tag,
const gchar *value);
static void metadata_dialog_add_translated_tag (GExiv2Metadata *metadata,
GtkListStore *store,
gint tag_column,
gint value_column,
const gchar *tag);
static gchar * metadata_interpret_user_comment (gchar *comment);
static gchar * metadata_dialog_format_tag_value (GExiv2Metadata *metadata,
const gchar *tag,
gboolean truncate);
static gchar * metadata_format_string_value (const gchar *value,
gboolean truncate);
static inline gboolean metadata_tag_is_string (const gchar *tag);
G_DEFINE_TYPE (Metadata, metadata, PIKA_TYPE_PLUG_IN)
PIKA_MAIN (METADATA_TYPE)
DEFINE_STD_SET_I18N
static void
metadata_class_init (MetadataClass *klass)
{
PikaPlugInClass *plug_in_class = PIKA_PLUG_IN_CLASS (klass);
plug_in_class->query_procedures = metadata_query_procedures;
plug_in_class->create_procedure = metadata_create_procedure;
plug_in_class->set_i18n = STD_SET_I18N;
}
static void
metadata_init (Metadata *metadata)
{
}
static GList *
metadata_query_procedures (PikaPlugIn *plug_in)
{
return g_list_append (NULL, g_strdup (PLUG_IN_PROC));
}
static PikaProcedure *
metadata_create_procedure (PikaPlugIn *plug_in,
const gchar *name)
{
PikaProcedure *procedure = NULL;
if (! strcmp (name, PLUG_IN_PROC))
{
procedure = pika_procedure_new (plug_in, name,
PIKA_PDB_PROC_TYPE_PLUGIN,
metadata_run, NULL, NULL);
pika_procedure_set_image_types (procedure, "*");
pika_procedure_set_menu_label (procedure, _("_View Metadata"));
pika_procedure_add_menu_path (procedure, "<Image>/Image/Metadata");
pika_procedure_set_documentation (procedure,
_("View metadata (Exif, IPTC, XMP)"),
"View metadata information attached "
"to the current image. This can "
"include Exif, IPTC and/or XMP "
"information.",
name);
pika_procedure_set_attribution (procedure,
"Hartmut Kuhse, Michael Natterer, "
"Ben Touchette",
"Hartmut Kuhse, Michael Natterer, "
"Ben Touchette",
"2013, 2017");
PIKA_PROC_ARG_ENUM (procedure, "run-mode",
"Run mode",
"The run mode",
PIKA_TYPE_RUN_MODE,
PIKA_RUN_INTERACTIVE,
G_PARAM_READWRITE);
PIKA_PROC_ARG_IMAGE (procedure, "image",
"Image",
"The input image",
FALSE,
G_PARAM_READWRITE);
}
return procedure;
}
static PikaValueArray *
metadata_run (PikaProcedure *procedure,
const PikaValueArray *args,
gpointer run_data)
{
PikaImage *image;
PikaMetadata *metadata;
GError *error = NULL;
pika_ui_init (PLUG_IN_BINARY);
image = PIKA_VALUES_GET_IMAGE (args, 1);
metadata = pika_image_get_metadata (image);
/* Always show metadata dialog so we can add appropriate iptc data
* as needed. Sometimes license data needs to be added after the
* fact and the image may not contain metadata but should have it
* added as needed.
*/
if (! metadata)
{
metadata = pika_metadata_new ();
pika_image_set_metadata (image, metadata);
}
if (metadata_viewer_dialog (image, metadata, &error))
return pika_procedure_new_return_values (procedure, PIKA_PDB_SUCCESS, NULL);
else
return pika_procedure_new_return_values (procedure, PIKA_PDB_EXECUTION_ERROR, error);
}
static gboolean
metadata_viewer_dialog (PikaImage *image,
PikaMetadata *g_metadata,
GError **error)
{
gchar *title;
gchar *name;
GtkWidget *dialog;
GtkWidget *content_area;
GtkWidget *metadata_vbox;
GtkWidget *notebook;
GtkWidget *scrolled_win;
GtkWidget *list_view;
GtkWidget *label;
GtkListStore *exif_store, *xmp_store, *iptc_store;
GtkCellRenderer *rend;
GtkTreeViewColumn *col;
GExiv2Metadata *metadata;
metadata = GEXIV2_METADATA(g_metadata);
name = pika_image_get_name (image);
title = g_strdup_printf (_("Metadata Viewer: %s"), name);
g_free (name);
dialog = pika_dialog_new (title,
"pika-metadata-viewer-dialog",
NULL, 0,
pika_standard_help_func, PLUG_IN_PROC,
_("_Close"), GTK_RESPONSE_CLOSE,
NULL);
gtk_widget_set_size_request(dialog, 650, 500);
g_free (title);
pika_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_CLOSE,
-1);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
/* Top-level Box */
metadata_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (content_area), metadata_vbox);
gtk_container_set_border_width (GTK_CONTAINER (metadata_vbox), 12);
gtk_widget_show (metadata_vbox);
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (metadata_vbox), notebook, TRUE, TRUE, 0);
/* EXIF tab */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 6);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
exif_store = gtk_list_store_new (NUM_EXIF_COLS,
G_TYPE_STRING, /* column-name c_exif_tag */
G_TYPE_STRING); /* column-name c_exif_value */
list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (exif_store));
gtk_widget_set_vexpand (list_view, TRUE);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("Exif Tag"),
rend,
"text", C_EXIF_TAG,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_spacing (col, 3);
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), col);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("Value"),
rend,
"text", C_EXIF_VALUE,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_spacing (col, 3);
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), col);
label = gtk_label_new (_("Exif"));
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_win, label);
gtk_container_add (GTK_CONTAINER (scrolled_win), list_view);
gtk_widget_show (list_view);
gtk_widget_show (scrolled_win);
/* XMP tab */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 6);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
xmp_store = gtk_list_store_new (NUM_XMP_COLS,
G_TYPE_STRING, /* column-name c_xmp_tag */
G_TYPE_STRING); /* column-name c_xmp_value */
list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (xmp_store));
gtk_widget_set_vexpand (list_view, TRUE);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("XMP Tag"),
rend,
"text", C_XMP_TAG,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_spacing (col, 3);
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), col);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("Value"),
rend,
"text", C_XMP_VALUE,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_spacing (col, 3);
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), col);
label = gtk_label_new (_("XMP"));
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_win, label);
gtk_container_add (GTK_CONTAINER (scrolled_win), list_view);
gtk_widget_show (list_view);
gtk_widget_show (scrolled_win);
/* IPTC tab */
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 6);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
iptc_store = gtk_list_store_new (NUM_IPTC_COLS,
G_TYPE_STRING, /* column-name c_iptc_tag */
G_TYPE_STRING); /* column-name c_iptc_value */
list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (iptc_store));
gtk_widget_set_vexpand (list_view, TRUE);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("IPTC Tag"),
rend,
"text", C_IPTC_TAG,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_spacing (col, 3);
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), col);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (_("Value"),
rend,
"text", C_IPTC_VALUE,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_spacing (col, 3);
gtk_tree_view_append_column (GTK_TREE_VIEW (list_view), col);
label = gtk_label_new (_("IPTC"));
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_win, label);
gtk_container_add (GTK_CONTAINER (scrolled_win), list_view);
gtk_widget_show (list_view);
gtk_widget_show (scrolled_win);
gtk_widget_show (notebook);
/* Add the metadata to the tree views */
metadata_dialog_set_metadata (metadata, exif_store, xmp_store, iptc_store);
g_object_unref (exif_store);
g_object_unref (xmp_store);
g_object_unref (iptc_store);
gtk_dialog_run (GTK_DIALOG (dialog));
return TRUE;
}
/* private functions */
static void
metadata_dialog_set_metadata (GExiv2Metadata *metadata,
GtkListStore *exif_store,
GtkListStore *xmp_store,
GtkListStore *iptc_store)
{
gchar **tags;
/* load exif tags */
tags = gexiv2_metadata_get_exif_tags (metadata);
metadata_dialog_append_tags (metadata, tags, exif_store, C_EXIF_TAG, C_EXIF_VALUE, FALSE);
g_strfreev (tags);
/* load xmp tags */
tags = gexiv2_metadata_get_xmp_tags (metadata);
metadata_dialog_append_tags (metadata, tags, xmp_store, C_XMP_TAG, C_XMP_VALUE, FALSE);
g_strfreev (tags);
/* load iptc tags */
tags = gexiv2_metadata_get_iptc_tags (metadata);
metadata_dialog_append_tags (metadata, tags, iptc_store, C_IPTC_TAG, C_IPTC_VALUE, TRUE);
g_strfreev (tags);
}
static gchar *
metadata_format_string_value (const gchar *value,
gboolean truncate)
{
glong size;
gchar *result;
size = g_utf8_strlen (value, -1);
if (! truncate || size <= TAG_VALUE_MAX_SIZE)
{
result = g_strdup(value);
}
else
{
gchar *value_utf8_trunc;
GString *str;
value_utf8_trunc = g_utf8_substring (value, 0, TAG_VALUE_MAX_SIZE);
str = g_string_new (value_utf8_trunc);
g_free (value_utf8_trunc);
g_string_append (str, "... ");
g_string_append_printf (str,
_("(%lu more character(s))"),
size - TAG_VALUE_MAX_SIZE);
result = g_string_free (str, FALSE);
}
return result;
}
static inline gboolean
metadata_tag_is_string (const gchar *tag)
{
const gchar *tag_type;
GError *error = NULL;
tag_type = gexiv2_metadata_try_get_tag_type (tag, &error);
if (error)
{
g_printerr ("%s: Failed to get metadata tag type for tag %s: %s",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
return FALSE;
}
return (g_strcmp0 (tag_type, "Byte") != 0 &&
g_strcmp0 (tag_type, "Undefined") != 0 &&
g_strcmp0 (tag_type, NULL) != 0);
}
static void
metadata_dialog_add_tag (GtkListStore *store,
gint tag_column,
gint value_column,
const gchar *tag,
const gchar *value)
{
if (value)
{
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
tag_column, tag,
value_column, value,
-1);
}
}
static void
metadata_dialog_add_translated_tag (GExiv2Metadata *metadata,
GtkListStore *store,
gint tag_column,
gint value_column,
const gchar *tag)
{
gchar *value = NULL;
GError *error = NULL;
value = gexiv2_metadata_try_get_tag_interpreted_string (metadata, tag, &error);
if (error)
{
g_printerr ("%s: unreadable '%s' metadata tag: %s\n",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
}
metadata_dialog_add_tag (store, tag_column, value_column,
tag, gettext (value));
g_free (value);
}
static gchar *
metadata_interpret_user_comment (gchar *comment)
{
/* Exiv2 can return unwanted text at the start of a comment
* taken from Exif.Photo.UserComment since 0.27.3.
* Let's remove that part and replace with an empty string
* if there is nothing else left as comment. */
if (comment && g_str_has_prefix (comment, "charset=Ascii "))
{
gchar *real_comment;
/* Skip "charset=Ascii " (length 14) to find the real comment */
real_comment = comment + 14;
if (real_comment[0] == '\0' ||
! g_strcmp0 (real_comment, "binary comment"))
{
g_free (comment);
/* Make empty comment instead of returning NULL or else
* the exif value will not be shown at all. */
comment = g_strdup ("");
}
else
{
real_comment = g_strdup (real_comment);
g_free (comment);
return real_comment;
}
}
return comment;
}
static void
metadata_dialog_add_multiple_values (GExiv2Metadata *metadata,
const gchar *tag,
GtkListStore *store,
gint tag_column,
gint value_column)
{
gchar **values;
GError *error = NULL;
values = gexiv2_metadata_try_get_tag_multiple (GEXIV2_METADATA (metadata), tag, &error);
if (error)
{
g_printerr ("%s: unreadable '%s' metadata tag: %s\n",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
}
if (values)
{
gint i;
for (i = 0; values[i] != NULL; i++)
{
gchar *value;
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
value = metadata_format_string_value (values[i], /* truncate = */ TRUE);
gtk_list_store_set (store, &iter,
tag_column, tag,
value_column, value,
-1);
g_free (value);
}
g_strfreev (values);
}
}
static void
metadata_dialog_append_tags (GExiv2Metadata *metadata,
gchar **tags,
GtkListStore *store,
gint tag_column,
gint value_column,
gboolean load_iptc)
{
const gchar *tag;
const gchar *last_tag = NULL;
gboolean gps_done = FALSE;
while ((tag = *tags++))
{
gchar *value;
/* We need special handling for iptc tags like "Keywords" which
* can appear multiple times. For now assuming that this can
* only happen for iptc tags of String and related types.
* See also: https://exiv2.org/iptc.html which only lists
* one Date type as repeatable (Iptc.Application2.ReferenceDate),
* and Date is handled here as string.
*/
if (load_iptc && metadata_tag_is_string (tag))
{
if (last_tag && ! strcmp (tag, last_tag))
{
continue;
}
last_tag = tag;
metadata_dialog_add_multiple_values (GEXIV2_METADATA (metadata),
tag, store,
tag_column,
value_column);
}
else if (! strcmp ("Exif.GPSInfo.GPSLongitude", tag) ||
! strcmp ("Exif.GPSInfo.GPSLongitudeRef", tag) ||
! strcmp ("Exif.GPSInfo.GPSLatitude", tag) ||
! strcmp ("Exif.GPSInfo.GPSLatitudeRef", tag) ||
! strcmp ("Exif.GPSInfo.GPSAltitude", tag) ||
! strcmp ("Exif.GPSInfo.GPSAltitudeRef", tag))
{
/* We need special handling for some of the GPS tags to
* be able to show better values than the default. */
if (! gps_done)
{
gdouble lng, lat, alt;
gchar *str;
gchar *value;
GError *error = NULL;
if (gexiv2_metadata_try_get_gps_longitude (GEXIV2_METADATA (metadata),
&lng, &error))
{
str = metadata_format_gps_longitude_latitude (lng);
metadata_dialog_add_tag (store,
tag_column, value_column,
"Exif.GPSInfo.GPSLongitude",
str);
g_free (str);
}
else if (error)
{
g_printerr ("%s: unreadable gps longitude tag: %s\n",
G_STRFUNC, error->message);
g_clear_error (&error);
}
metadata_dialog_add_translated_tag (metadata, store,
tag_column, value_column,
"Exif.GPSInfo.GPSLongitudeRef");
if (gexiv2_metadata_try_get_gps_latitude (GEXIV2_METADATA (metadata),
&lat, &error))
{
str = metadata_format_gps_longitude_latitude (lat);
metadata_dialog_add_tag (store,
tag_column, value_column,
"Exif.GPSInfo.GPSLatitude",
str);
g_free (str);
}
else if (error)
{
g_printerr ("%s: unreadable gps latitude tag: %s\n",
G_STRFUNC, error->message);
g_clear_error (&error);
}
metadata_dialog_add_translated_tag (metadata, store,
tag_column, value_column,
"Exif.GPSInfo.GPSLatitudeRef");
if (gexiv2_metadata_try_get_gps_altitude (GEXIV2_METADATA (metadata),
&alt, &error))
{
gchar *str2, *str3;
GError *error = NULL;
str = metadata_format_gps_altitude (alt, TRUE, _(" meter"));
str2 = metadata_format_gps_altitude (alt, FALSE, _(" feet"));
str3 = g_strdup_printf ("%s (%s)", str, str2);
metadata_dialog_add_tag (store,
tag_column, value_column,
"Exif.GPSInfo.GPSAltitude",
str3);
g_free (str);
g_free (str2);
g_free (str3);
value = gexiv2_metadata_try_get_tag_string (metadata,
"Exif.GPSInfo.GPSAltitudeRef",
&error);
if (error)
{
g_printerr ("%s: unreadable '%s' metadata tag: %s\n",
G_STRFUNC, "Exif.GPSInfo.GPSAltitudeRef",
error->message);
g_clear_error (&error);
}
if (value)
{
gint index;
if (value[0] == '0')
index = 1;
else if (value[0] == '1')
index = 2;
else
index = 0;
metadata_dialog_add_tag (store,
tag_column, value_column,
"Exif.GPSInfo.GPSAltitudeRef",
gettext (gpsaltref[index]));
g_free (value);
}
}
else if (error)
{
g_printerr ("%s: unreadable gps altitude tag: %s\n",
G_STRFUNC, error->message);
g_clear_error (&error);
}
gps_done = TRUE;
}
}
else if (! strcmp ("Exif.Photo.UserComment", tag))
{
GError *error = NULL;
value = gexiv2_metadata_try_get_tag_interpreted_string (metadata, tag, &error);
if (error)
{
g_printerr ("%s: unreadable '%s' metadata tag: %s\n",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
}
/* Can start with charset. Remove part that is not relevant. */
value = metadata_interpret_user_comment (value);
metadata_dialog_add_tag (store,
tag_column, value_column,
tag, value);
g_free (value);
}
else
{
if (g_str_has_prefix (tag, "Xmp."))
{
GError *error = NULL;
const gchar *tag_type;
tag_type = gexiv2_metadata_try_get_tag_type (tag, &error);
if (error)
{
g_printerr ("%s: Failed to get metadata tag type for tag %s: %s",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
}
else if (g_strcmp0 (tag_type, "XmpText") != 0)
{
metadata_dialog_add_multiple_values (GEXIV2_METADATA (metadata),
tag, store,
tag_column,
value_column);
continue;
}
}
value = metadata_dialog_format_tag_value (metadata, tag,
/* truncate = */ TRUE);
metadata_dialog_add_tag (store,
tag_column, value_column,
tag, value);
g_free (value);
}
}
}
static gchar *
metadata_dialog_format_tag_value (GExiv2Metadata *metadata,
const gchar *tag,
gboolean truncate)
{
gchar *result;
if (metadata_tag_is_string(tag))
{
gchar *value;
gchar *value_utf8;
GError *error = NULL;
value = gexiv2_metadata_try_get_tag_interpreted_string (metadata, tag, &error);
if (error)
{
g_printerr ("%s: unreadable '%s' metadata tag: %s\n",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
}
if (! g_utf8_validate (value, -1, NULL))
{
value_utf8 = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
}
else
{
value_utf8 = g_strdup (value);
}
g_free (value);
result = metadata_format_string_value (value_utf8, truncate);
}
else
{
GBytes *bytes;
const guchar *data;
gsize size;
gsize display_size;
GString *str;
gint i;
GError *error = NULL;
bytes = gexiv2_metadata_try_get_tag_raw (metadata, tag, &error);
if (error)
{
g_printerr ("%s: unreadable '%s' metadata tag: %s\n",
G_STRFUNC, tag, error->message);
g_clear_error (&error);
}
data = g_bytes_get_data (bytes, &size);
if (! truncate)
display_size = size;
else
display_size = MIN (size, RAW_DATA_MAX_SIZE);
str = g_string_sized_new (3 * display_size);
for (i = 0; i < display_size; i++)
g_string_append_printf (str, i == 0 ? "%02x" : " %02x", data[i]);
if (display_size < size)
{
g_string_append (str, " ... ");
g_string_append_printf (str,
_("(%llu more byte(s))"),
(unsigned long long) (size - display_size));
}
result = g_string_free (str, FALSE);
g_bytes_unref (bytes);
}
return result;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,102 @@
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2016, 2017 Ben Touchette
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __METADATA_XML_H__
#define __METADATA_XML_H__
#include "metadata-misc.h"
struct _PikaXmlParser
{
GMarkupParseContext *context;
};
typedef struct _PikaXmlParser PikaXmlParser;
void
xml_parser_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
gpointer user_data,
GError **error);
void
xml_parser_data (GMarkupParseContext *context,
const gchar *text,
gsize text_len,
gpointer user_data,
GError **error);
void
set_tag_ui (metadata_editor *args,
gint index,
gchar *name,
gchar *value,
MetadataMode mode);
const gchar *
get_tag_ui_text (metadata_editor *args,
gchar *name,
MetadataMode mode);
gchar *
get_tag_ui_list (metadata_editor *args,
gchar *name,
MetadataMode mode);
gint
get_tag_ui_combo (metadata_editor *args,
gchar *name,
MetadataMode mode);
void
xml_parser_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error);
gboolean
xml_parser_parse_file (PikaXmlParser *parser,
const gchar *filename,
GError **error);
void
xml_parser_free (PikaXmlParser *parser);
gboolean
parse_encoding (const gchar *text,
gint text_len,
gchar **encoding);
gboolean
xml_parser_parse_io_channel (PikaXmlParser *parser,
GIOChannel *io,
GError **error);
PikaXmlParser *
xml_parser_new (const GMarkupParser *markup_parser,
gpointer user_data);
#endif /* __METADATA_XML_H__ */