libheif
Loading...
Searching...
No Matches
heif_items.h
Go to the documentation of this file.
1/*
2 * HEIF codec.
3 * Copyright (c) 2023 Dirk Farin <dirk.farin@gmail.com>
4 *
5 * This file is part of libheif.
6 *
7 * libheif is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * libheif is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with libheif. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef LIBHEIF_HEIF_ITEMS_H
22#define LIBHEIF_HEIF_ITEMS_H
23
24#include "heif_library.h"
25#include "heif_error.h"
26#include "heif_metadata.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
42LIBHEIF_API
44
55LIBHEIF_API
57 heif_item_id* ID_array,
58 int count);
59
71LIBHEIF_API
73
74#define heif_item_type_mime heif_fourcc('m','i','m','e')
75#define heif_item_type_uri heif_fourcc('u','r','i',' ')
76#define heif_item_type_exif heif_fourcc('E','x','i','f')
77#define heif_item_type_grid heif_fourcc('g','r','i','d')
78#define heif_item_type_hvc1 heif_fourcc('h','v','c','1')
79#define heif_item_type_unci heif_fourcc('u','n','c','i')
80#define heif_item_type_av01 heif_fourcc('a','v','0','1')
81#define heif_item_type_avc1 heif_fourcc('a','v','c','1')
82
83LIBHEIF_API
85
86
97LIBHEIF_API
99
112LIBHEIF_API
114
125LIBHEIF_API
127
128LIBHEIF_API
129const char* heif_item_get_item_name(const heif_context* ctx, heif_item_id item_id);
130
131LIBHEIF_API
133 heif_item_id item,
134 const char* item_name);
135
136
159LIBHEIF_API
161 heif_item_id item_id,
162 enum heif_metadata_compression* out_compression_format,
163 uint8_t** out_data, size_t* out_data_size);
164
174LIBHEIF_API
175void heif_release_item_data(const heif_context* ctx, uint8_t** item_data);
176
177
178// ------------------------- item language -------------------------
179
189LIBHEIF_API
191 heif_item_id itemId,
192 char** out_language);
193
194LIBHEIF_API
196 heif_item_id item_id,
197 const char* language, heif_property_id* out_optional_propertyId);
198
199// ------------------------- item references -------------------------
200
211LIBHEIF_API
213 heif_item_id from_item_id,
214 int index,
215 uint32_t* out_reference_type_4cc,
216 heif_item_id** out_references_to);
217
218LIBHEIF_API
220
221LIBHEIF_API
223 uint32_t reference_type,
224 heif_item_id from_item,
225 heif_item_id to_item);
226
227LIBHEIF_API
229 uint32_t reference_type,
230 heif_item_id from_item,
231 const heif_item_id* to_item,
232 int num_to_items);
233
234// ------------------------- adding new items -------------------------
235
236/*
237 * All functions in this section add a new item to the context and return its ID in
238 * 'out_item_id'. The item ID is freshly allocated and does not collide with any item that
239 * already exists in the context, including items read from an input file.
240 *
241 * 'data' is copied into the context, the caller may release it afterwards. 'size' is the
242 * number of bytes in 'data'. A NULL 'data' is only allowed together with size 0.
243 * 'out_item_id' may be NULL, in which case the item is added but its ID is not reported.
244 *
245 * The new item is marked as hidden. Use heif_context_add_item_reference() to link it to an
246 * image (e.g. with a 'cdsc' reference for metadata that describes the image).
247 *
248 * Note that a file must contain at least one image or image sequence to be written;
249 * a context holding only items added with these functions cannot be written.
250 */
251
261LIBHEIF_API
263 const char* item_type,
264 const void* data, int size,
265 heif_item_id* out_item_id);
266
280LIBHEIF_API
282 const char* content_type,
283 enum heif_metadata_compression content_encoding,
284 const void* data, int size,
285 heif_item_id* out_item_id);
286
302LIBHEIF_API
304 const char* content_type,
305 const char* content_encoding,
306 const void* data, int size,
307 heif_item_id* out_item_id);
308
318LIBHEIF_API
320 const char* item_uri_type,
321 const void* data, int size,
322 heif_item_id* out_item_id);
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif
heif_error heif_item_set_property_extended_language(heif_context *context, heif_item_id item_id, const char *language, heif_property_id *out_optional_propertyId)
const char * heif_item_get_mime_item_content_type(const heif_context *ctx, heif_item_id item_id)
Gets the MIME content_type for an item.
int heif_context_get_number_of_items(const heif_context *ctx)
Gets the number of items.
heif_error heif_item_get_property_extended_language(const heif_context *context, heif_item_id itemId, char **out_language)
Get the extended language associated with the item.
heif_error heif_item_get_item_data(const heif_context *ctx, heif_item_id item_id, enum heif_metadata_compression *out_compression_format, uint8_t **out_data, size_t *out_data_size)
Gets the raw metadata, as stored in the HEIF file.
heif_error heif_context_add_uri_item(heif_context *ctx, const char *item_uri_type, const void *data, int size, heif_item_id *out_item_id)
Add a 'uri ' item.
heif_error heif_context_add_item_reference(heif_context *ctx, uint32_t reference_type, heif_item_id from_item, heif_item_id to_item)
const char * heif_item_get_item_name(const heif_context *ctx, heif_item_id item_id)
void heif_release_item_references(const heif_context *ctx, heif_item_id **references)
heif_error heif_context_add_mime_item(heif_context *ctx, const char *content_type, enum heif_metadata_compression content_encoding, const void *data, int size, heif_item_id *out_item_id)
Add a 'mime' item, optionally compressing the payload.
void heif_release_item_data(const heif_context *ctx, uint8_t **item_data)
Free the item data.
const char * heif_item_get_mime_item_content_encoding(const heif_context *ctx, heif_item_id item_id)
Gets the content_encoding for a MIME item.
int heif_context_get_list_of_item_IDs(const heif_context *ctx, heif_item_id *ID_array, int count)
Get the item identifiers.
uint32_t heif_item_get_item_type(const heif_context *ctx, heif_item_id item_id)
Gets the item type.
heif_error heif_context_add_item(heif_context *ctx, const char *item_type, const void *data, int size, heif_item_id *out_item_id)
Add an item with an arbitrary four-character item type (e.g.
heif_error heif_context_add_item_references(heif_context *ctx, uint32_t reference_type, heif_item_id from_item, const heif_item_id *to_item, int num_to_items)
heif_error heif_item_set_item_name(heif_context *ctx, heif_item_id item, const char *item_name)
size_t heif_context_get_item_references(const heif_context *ctx, heif_item_id from_item_id, int index, uint32_t *out_reference_type_4cc, heif_item_id **out_references_to)
Get the item ids that reference the given item.
heif_error heif_context_add_precompressed_mime_item(heif_context *ctx, const char *content_type, const char *content_encoding, const void *data, int size, heif_item_id *out_item_id)
Add a 'mime' item whose payload has already been compressed by the caller.
const char * heif_item_get_uri_item_uri_type(const heif_context *ctx, heif_item_id item_id)
Gets the item_uri_type for an item.
int heif_item_is_item_hidden(const heif_context *ctx, heif_item_id item_id)
uint32_t heif_property_id
Definition heif_library.h:93
uint32_t heif_item_id
Definition heif_library.h:92
struct heif_context heif_context
Definition heif_library.h:89