Skip to content

Commit

Permalink
Merge branch 'master' of github.com:strukturag/libheif
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 12, 2023
2 parents bcef7a2 + d55b1c3 commit 34b9468
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/heif_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,14 @@ int main(int argc, char** argv)
for (int n = 0; n < numMetadata; n++) {
std::string itemtype = heif_image_handle_get_metadata_type(handle, ids[n]);
std::string contenttype = heif_image_handle_get_metadata_content_type(handle, ids[n]);
std::string item_uri_type = heif_image_handle_get_metadata_item_uri_type(handle, ids[n]);
std::string ID{"unknown"};
if (itemtype == "Exif") {
ID = itemtype;
}
else if (itemtype == "uri ") {
ID = itemtype + "/" + item_uri_type;
}
else if (contenttype == "application/rdf+xml") {
ID = "XMP";
}
Expand Down
2 changes: 2 additions & 0 deletions libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ class Box_infe : public FullBox

Error write(StreamWriter& writer) const override;

const std::string& get_item_uri_type() const { return m_item_uri_type; }

protected:
Error parse(BitstreamRange& range) override;

Expand Down
3 changes: 3 additions & 0 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,15 @@ Error HeifContext::interpret_heif_file()
}
std::string content_type = m_heif_file->get_content_type(id);

std::string item_uri_type = m_heif_file->get_item_uri_type(id);

// we now assign all kinds of metadata to the image, not only 'Exif' and 'XMP'

std::shared_ptr<ImageMetadata> metadata = std::make_shared<ImageMetadata>();
metadata->item_id = id;
metadata->item_type = item_type;
metadata->content_type = content_type;
metadata->item_uri_type = item_uri_type;

Error err = m_heif_file->get_compressed_image_data(id, &(metadata->m_data));
if (err) {
Expand Down
1 change: 1 addition & 0 deletions libheif/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ImageMetadata
heif_item_id item_id;
std::string item_type; // e.g. "Exif"
std::string content_type;
std::string item_uri_type;
std::vector<uint8_t> m_data;
};

Expand Down
10 changes: 10 additions & 0 deletions libheif/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,16 @@ std::string HeifFile::get_content_type(heif_item_id ID) const
return infe_box->get_content_type();
}

std::string HeifFile::get_item_uri_type(heif_item_id ID) const
{
auto infe_box = get_infe(ID);
if (!infe_box) {
return "";
}

return infe_box->get_item_uri_type();
}


Error HeifFile::get_properties(heif_item_id imageID,
std::vector<std::shared_ptr<Box>>& properties) const
Expand Down
2 changes: 2 additions & 0 deletions libheif/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class HeifFile

std::string get_content_type(heif_item_id ID) const;

std::string get_item_uri_type(heif_item_id ID) const;

Error get_compressed_image_data(heif_item_id ID, std::vector<uint8_t>* out_data) const;


Expand Down
13 changes: 13 additions & 0 deletions libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,19 @@ const char* heif_image_handle_get_metadata_content_type(const struct heif_image_
}


const char* heif_image_handle_get_metadata_item_uri_type(const struct heif_image_handle* handle,
heif_item_id metadata_id)
{
for (auto& metadata : handle->image->get_metadata()) {
if (metadata->item_id == metadata_id) {
return metadata->item_uri_type.c_str();
}
}

return nullptr;
}


size_t heif_image_handle_get_metadata_size(const struct heif_image_handle* handle,
heif_item_id metadata_id)
{
Expand Down
4 changes: 4 additions & 0 deletions libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,10 @@ struct heif_error heif_image_handle_get_metadata(const struct heif_image_handle*
heif_item_id metadata_id,
void* out_data);

// Only valid for item type == "uri ", an absolute URI
LIBHEIF_API
const char* heif_image_handle_get_metadata_item_uri_type(const struct heif_image_handle* handle,
heif_item_id metadata_id);

// ------------------------- color profiles -------------------------

Expand Down

0 comments on commit 34b9468

Please sign in to comment.