From 2289041ad985efca583841052d92f7dbe6d77f57 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Wed, 1 Nov 2023 15:31:31 +0100 Subject: [PATCH 1/3] Revert "add heif_context_add_generic_uri_metadata()" This reverts commit 06f13d1a559f73ed05bae96a4df3e95f19269c47. New API will be developed in branch develop-v1.18.0. --- libheif/box.h | 2 -- libheif/context.cc | 9 +++------ libheif/context.h | 2 +- libheif/heif.cc | 18 +----------------- libheif/heif.h | 8 -------- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/libheif/box.h b/libheif/box.h index 7e15d23bc7..3a651f6ea9 100644 --- a/libheif/box.h +++ b/libheif/box.h @@ -471,8 +471,6 @@ class Box_infe : public FullBox Error write(StreamWriter& writer) const override; - void set_item_uri_type(const std::string& type) { m_item_uri_type = type; } - const std::string& get_item_uri_type() const { return m_item_uri_type; } protected: diff --git a/libheif/context.cc b/libheif/context.cc index 551d1ae7de..392eac1b80 100644 --- a/libheif/context.cc +++ b/libheif/context.cc @@ -3324,19 +3324,19 @@ Error HeifContext::add_exif_metadata(const std::shared_ptr& master_image, return add_generic_metadata(master_image, data_array.data(), (int) data_array.size(), - "Exif", nullptr, nullptr, heif_metadata_compression_off); + "Exif", nullptr, heif_metadata_compression_off); } Error HeifContext::add_XMP_metadata(const std::shared_ptr& master_image, const void* data, int size, heif_metadata_compression compression) { - return add_generic_metadata(master_image, data, size, "mime", "application/rdf+xml", nullptr, compression); + return add_generic_metadata(master_image, data, size, "mime", "application/rdf+xml", compression); } Error HeifContext::add_generic_metadata(const std::shared_ptr& master_image, const void* data, int size, - const char* item_type, const char* content_type, const char* item_uri_type, heif_metadata_compression compression) + const char* item_type, const char* content_type, heif_metadata_compression compression) { // create an infe box describing what kind of data we are storing (this also creates a new ID) @@ -3345,9 +3345,6 @@ Error HeifContext::add_generic_metadata(const std::shared_ptr& master_ima if (content_type != nullptr) { metadata_infe_box->set_content_type(content_type); } - if (item_uri_type != nullptr) { - metadata_infe_box->set_item_uri_type(item_uri_type); - } heif_item_id metadata_id = metadata_infe_box->get_item_ID(); diff --git a/libheif/context.h b/libheif/context.h index ab6f78fadd..6e88d85022 100644 --- a/libheif/context.h +++ b/libheif/context.h @@ -449,7 +449,7 @@ class HeifContext : public ErrorBuffer Error add_XMP_metadata(const std::shared_ptr& master_image, const void* data, int size, heif_metadata_compression compression); Error add_generic_metadata(const std::shared_ptr& master_image, const void* data, int size, - const char* item_type, const char* content_type, const char* item_uri_type, + const char* item_type, const char* content_type, heif_metadata_compression compression); heif_property_id add_property(heif_item_id targetItem, std::shared_ptr property, bool essential); diff --git a/libheif/heif.cc b/libheif/heif.cc index 37ac6b1010..6f7f614989 100644 --- a/libheif/heif.cc +++ b/libheif/heif.cc @@ -2829,23 +2829,7 @@ struct heif_error heif_context_add_generic_metadata(struct heif_context* ctx, const char* item_type, const char* content_type) { Error error = ctx->context->add_generic_metadata(image_handle->image, data, size, - item_type, content_type, nullptr, heif_metadata_compression_off); - if (error != Error::Ok) { - return error.error_struct(ctx->context.get()); - } - else { - return heif_error_success; - } -} - - -struct heif_error heif_context_add_generic_uri_metadata(struct heif_context* ctx, - const struct heif_image_handle* image_handle, - const void* data, int size, - const char* item_uri_type) -{ - Error error = ctx->context->add_generic_metadata(image_handle->image, data, size, - "uri ", nullptr, item_uri_type, heif_metadata_compression_off); + item_type, content_type, heif_metadata_compression_off); if (error != Error::Ok) { return error.error_struct(ctx->context.get()); } diff --git a/libheif/heif.h b/libheif/heif.h index e05cb431e9..0c25f5eada 100644 --- a/libheif/heif.h +++ b/libheif/heif.h @@ -2088,14 +2088,6 @@ struct heif_error heif_context_add_generic_metadata(struct heif_context* ctx, const void* data, int size, const char* item_type, const char* content_type); -// Add generic metadata with item_type "uri ". Items with this type do not have a content_type, but -// an item_uri_type and they have no content_encoding (they are always stored uncompressed). -LIBHEIF_API -struct heif_error heif_context_add_generic_uri_metadata(struct heif_context* ctx, - const struct heif_image_handle* image_handle, - const void* data, int size, - const char* item_uri_type); - // --- heif_image allocation // Create a new image of the specified resolution and colorspace. From 3b1f4650b6b0756cc0afcf6aed7f60c77e762444 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Thu, 2 Nov 2023 12:19:47 +0100 Subject: [PATCH 2/3] check whether libpng supports iTXt chunks (#1020) --- examples/decoder_png.cc | 2 ++ examples/encoder_png.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/decoder_png.cc b/examples/decoder_png.cc index 5f8feb3cc4..5742f02653 100644 --- a/examples/decoder_png.cc +++ b/examples/decoder_png.cc @@ -213,6 +213,7 @@ InputImage loadPNG(const char* filename, int output_bit_depth) // --- read XMP data +#ifdef PNG_iTXt_SUPPORTED png_textp textPtr = nullptr; const png_uint_32 nTextChunks = png_get_text(png_ptr, info_ptr, &textPtr, nullptr); for (png_uint_32 i = 0; i < nTextChunks; i++, textPtr++) { @@ -231,6 +232,7 @@ InputImage loadPNG(const char* filename, int output_bit_depth) } } } +#endif int band = png_get_channels(png_ptr, info_ptr); diff --git a/examples/encoder_png.cc b/examples/encoder_png.cc index e53660a1f1..a24b0593ea 100644 --- a/examples/encoder_png.cc +++ b/examples/encoder_png.cc @@ -134,6 +134,7 @@ bool PngEncoder::Encode(const struct heif_image_handle* handle, // --- write XMP metadata +#ifdef PNG_iTXt_SUPPORTED // spec: https://raw.githubusercontent.com/adobe/xmp-docs/master/XMPSpecifications/XMPSpecificationPart3.pdf std::vector xmp = get_xmp_metadata(handle); if (!xmp.empty()) { @@ -156,6 +157,7 @@ bool PngEncoder::Encode(const struct heif_image_handle* handle, xmp_text.itxt_length = text_length; png_set_text(png_ptr, info_ptr, &xmp_text, 1); } +#endif png_write_info(png_ptr, info_ptr); From c469dcbd8b70c32a51c393ecfc5c591c681868e1 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Thu, 2 Nov 2023 12:37:40 +0100 Subject: [PATCH 3/3] increase version to v1.17.2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f785a0a78c..1d7f2f4ae9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.16.3) # Oldest Ubuntu LTS (20.04 currently) -project(libheif LANGUAGES C CXX VERSION 1.17.1) +project(libheif LANGUAGES C CXX VERSION 1.17.2) # compatibility_version is never allowed to be decreased for any specific SONAME. # Libtool in the libheif-1.15.1 release had set it to 17.0.0, so we have to use this for the v1.x.y versions.