This source file includes following definitions.
- HasExifMetaData
- GetExifMetaData
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <stdlib.h>
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
#include "encoder.h"
#if defined(_MSC_VER)
#define strcasecmp _stricmp
#endif
static const char kMetadataTypeExif[] = "Exif";
bool Encoder::HasExifMetaData(const struct heif_image_handle* handle) {
heif_item_id metadata_id;
int count = heif_image_handle_get_list_of_metadata_block_IDs(handle, kMetadataTypeExif,
&metadata_id, 1);
return count > 0;
}
uint8_t* Encoder::GetExifMetaData(const struct heif_image_handle* handle, size_t* size) {
heif_item_id metadata_id;
int count = heif_image_handle_get_list_of_metadata_block_IDs(handle, kMetadataTypeExif,
&metadata_id, 1);
for (int i = 0; i < count; i++) {
size_t datasize = heif_image_handle_get_metadata_size(handle, metadata_id);
uint8_t* data = static_cast<uint8_t*>(malloc(datasize));
if (!data) {
continue;
}
heif_error error = heif_image_handle_get_metadata(handle, metadata_id, data);
if (error.code != heif_error_Ok) {
free(data);
continue;
}
*size = datasize;
return data;
}
return nullptr;
}