gimp/libgimpbase/gimpmetadata.h

159 lines
6.9 KiB
C
Raw Permalink Normal View History

/* LIBGIMPBASE - The GIMP Basic Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpmetadata.h
* Copyright (C) 2013 Hartmut Kuhse <hartmutkuhse@src.gnome.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_METADATA_H__
#define __GIMP_METADATA_H__
G_BEGIN_DECLS
#include <gexiv2/gexiv2.h>
#define GIMP_TYPE_METADATA (gimp_metadata_get_type ())
G_DECLARE_FINAL_TYPE (GimpMetadata, gimp_metadata, GIMP, METADATA, GExiv2Metadata)
/**
* GimpMetadataLoadFlags:
* @GIMP_METADATA_LOAD_NONE: Do not load the metadata
* @GIMP_METADATA_LOAD_COMMENT: Load the comment
* @GIMP_METADATA_LOAD_RESOLUTION: Load the resolution
* @GIMP_METADATA_LOAD_ORIENTATION: Load the orientation (rotation)
* @GIMP_METADATA_LOAD_COLORSPACE: Load the colorspace
* @GIMP_METADATA_LOAD_ALL: Load all of the above
*
* What metadata to load when importing images.
**/
typedef enum
{
GIMP_METADATA_LOAD_NONE = 0,
GIMP_METADATA_LOAD_COMMENT = 1 << 0,
GIMP_METADATA_LOAD_RESOLUTION = 1 << 1,
GIMP_METADATA_LOAD_ORIENTATION = 1 << 2,
GIMP_METADATA_LOAD_COLORSPACE = 1 << 3,
GIMP_METADATA_LOAD_ALL = 0xffffffff
} GimpMetadataLoadFlags;
/**
* GimpMetadataSaveFlags:
* @GIMP_METADATA_SAVE_EXIF: Save EXIF
* @GIMP_METADATA_SAVE_XMP: Save XMP
* @GIMP_METADATA_SAVE_IPTC: Save IPTC
* @GIMP_METADATA_SAVE_THUMBNAIL: Save a thumbnail of the image
* @GIMP_METADATA_SAVE_COLOR_PROFILE: Save the image's color profile
* Since: 2.10.10
* @GIMP_METADATA_SAVE_COMMENT: Save the image's comment
* Since: 3.0
* @GIMP_METADATA_SAVE_ALL: Save all of the above
*
* What kinds of metadata to save when exporting images.
**/
typedef enum
{
GIMP_METADATA_SAVE_EXIF = 1 << 0,
GIMP_METADATA_SAVE_XMP = 1 << 1,
GIMP_METADATA_SAVE_IPTC = 1 << 2,
GIMP_METADATA_SAVE_THUMBNAIL = 1 << 3,
GIMP_METADATA_SAVE_COLOR_PROFILE = 1 << 4,
GIMP_METADATA_SAVE_COMMENT = 1 << 5,
GIMP_METADATA_SAVE_ALL = 0xffffffff
} GimpMetadataSaveFlags;
/**
* GimpMetadataColorspace:
* @GIMP_METADATA_COLORSPACE_UNSPECIFIED: Unspecified
* @GIMP_METADATA_COLORSPACE_UNCALIBRATED: Uncalibrated
* @GIMP_METADATA_COLORSPACE_SRGB: sRGB
* @GIMP_METADATA_COLORSPACE_ADOBERGB: Adobe RGB
*
* Well-defined colorspace information available from metadata
**/
typedef enum
{
GIMP_METADATA_COLORSPACE_UNSPECIFIED,
GIMP_METADATA_COLORSPACE_UNCALIBRATED,
GIMP_METADATA_COLORSPACE_SRGB,
GIMP_METADATA_COLORSPACE_ADOBERGB
} GimpMetadataColorspace;
GimpMetadata * gimp_metadata_new (void);
GimpMetadata * gimp_metadata_duplicate (GimpMetadata *metadata);
GimpMetadata * gimp_metadata_deserialize (const gchar *metadata_xml);
gchar * gimp_metadata_serialize (GimpMetadata *metadata);
gchar * gimp_metadata_get_guid (void);
void gimp_metadata_add_xmp_history (GimpMetadata *metadata,
gchar *state_status);
GimpMetadata * gimp_metadata_load_from_file (GFile *file,
GError **error);
gboolean gimp_metadata_save_to_file (GimpMetadata *metadata,
GFile *file,
GError **error);
gboolean gimp_metadata_set_from_exif (GimpMetadata *metadata,
const guchar *exif_data,
gint exif_data_length,
GError **error);
gboolean gimp_metadata_set_from_iptc (GimpMetadata *metadata,
const guchar *iptc_data,
gint iptc_data_length,
GError **error);
gboolean gimp_metadata_set_from_xmp (GimpMetadata *metadata,
const guchar *xmp_data,
gint xmp_data_length,
GError **error);
void gimp_metadata_set_pixel_size (GimpMetadata *metadata,
gint width,
gint height);
void gimp_metadata_set_bits_per_sample (GimpMetadata *metadata,
gint bits_per_sample);
gboolean gimp_metadata_get_resolution (GimpMetadata *metadata,
gdouble *xres,
gdouble *yres,
Issue #8900 and #9923: reimplementing GimpUnit as a proper class. This fixes all our GObject Introspection issues with GimpUnit which was both an enum and an int-derived type of user-defined units *completing* the enum values. GIR clearly didn't like this! Now GimpUnit is a proper class and units are unique objects, allowing to compare them with an identity test (i.e. `unit == gimp_unit_pixel ()` tells us if unit is the pixel unit or not), which makes it easy to use, just like with int, yet adding also methods, making for nicer introspected API. As an aside, this also fixes #10738, by having all the built-in units retrievable even if libgimpbase had not been properly initialized with gimp_base_init(). I haven't checked in details how GIR works to introspect, but it looks like it loads the library to inspect and runs functions, hence triggering some CRITICALS because virtual methods (supposed to be initialized with gimp_base_init() run by libgimp) are not set. This new code won't trigger any critical because the vtable method are now not necessary, at least for all built-in units. Note that GimpUnit is still in libgimpbase. It could have been moved to libgimp in order to avoid any virtual method table (since we need to keep core and libgimp side's units in sync, PDB is required), but too many libgimpwidgets widgets were already using GimpUnit. And technically most of GimpUnit logic doesn't require PDB (only the creation/sync part). This is one of the reasons why user-created GimpUnit list is handled and stored differently from other types of objects. Globally this simplifies the code a lot too and we don't need separate implementations of various utils for core and libgimp, which means less prone to errors.
2024-07-25 20:55:21 +02:00
GimpUnit **unit);
void gimp_metadata_set_resolution (GimpMetadata *metadata,
gdouble xres,
gdouble yres,
Issue #8900 and #9923: reimplementing GimpUnit as a proper class. This fixes all our GObject Introspection issues with GimpUnit which was both an enum and an int-derived type of user-defined units *completing* the enum values. GIR clearly didn't like this! Now GimpUnit is a proper class and units are unique objects, allowing to compare them with an identity test (i.e. `unit == gimp_unit_pixel ()` tells us if unit is the pixel unit or not), which makes it easy to use, just like with int, yet adding also methods, making for nicer introspected API. As an aside, this also fixes #10738, by having all the built-in units retrievable even if libgimpbase had not been properly initialized with gimp_base_init(). I haven't checked in details how GIR works to introspect, but it looks like it loads the library to inspect and runs functions, hence triggering some CRITICALS because virtual methods (supposed to be initialized with gimp_base_init() run by libgimp) are not set. This new code won't trigger any critical because the vtable method are now not necessary, at least for all built-in units. Note that GimpUnit is still in libgimpbase. It could have been moved to libgimp in order to avoid any virtual method table (since we need to keep core and libgimp side's units in sync, PDB is required), but too many libgimpwidgets widgets were already using GimpUnit. And technically most of GimpUnit logic doesn't require PDB (only the creation/sync part). This is one of the reasons why user-created GimpUnit list is handled and stored differently from other types of objects. Globally this simplifies the code a lot too and we don't need separate implementations of various utils for core and libgimp, which means less prone to errors.
2024-07-25 20:55:21 +02:00
GimpUnit *unit);
void gimp_metadata_set_creation_date (GimpMetadata *metadata,
GDateTime *datetime);
GimpMetadataColorspace
gimp_metadata_get_colorspace (GimpMetadata *metadata);
void gimp_metadata_set_colorspace (GimpMetadata *metadata,
GimpMetadataColorspace colorspace);
gboolean gimp_metadata_is_tag_supported (const gchar *tag,
const gchar *mime_type);
G_END_DECLS
#endif /* __GIMP_METADATA_H__ */