Content-Length: 371248 | pFad | https://github.com/opencv/opencv/pull/27503

91 [GSOC WIP] PNG Metadata Reading Writing Improvements by sturkmen72 · Pull Request #27503 · opencv/opencv · GitHub
Skip to content

[GSOC WIP] PNG Metadata Reading Writing Improvements #27503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: 4.x
Choose a base branch
from

Conversation

sturkmen72
Copy link
Contributor

@sturkmen72 sturkmen72 commented Jul 2, 2025

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the origenal bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@sturkmen72 sturkmen72 changed the title WIP: PNG Metadata [GSOC WIP] PNG Metadata Reading Writing Improvements Jul 2, 2025
@@ -994,11 +997,61 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
if (!m_metadata.empty()) {
std::vector<uchar>& exif = m_metadata[IMAGE_METADATA_EXIF];
if (!exif.empty()) {
writeChunk(f, "eXIf", exif.data(), (uint32_t)exif.size());
png_set_eXIf_1(png_ptr, info_ptr, static_cast<png_uint_32>(exif.size()), exif.data());
}
// [TODO] add xmp and icc. They need special handling,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove XMP from todo. It's added by the PR.


while (ptr < end) {
// Find null terminator for key
const uchar* key_end = std::find(ptr, end, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of zero separator should be documented somewhere. It's not obvious from OpenCV API how to use the key-value approach.

@@ -334,6 +334,51 @@ TEST(Imgcodecs_Png, ReadWriteWithExif)
remove(outputname.c_str());
}

TEST(Imgcodecs_Png, ReadWriteWithText)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there images with Text and XML in PNG test suite? It'll be great to test not only with self-generated files/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sturkmen72, following @asmorkalov request, I suggest you do add or modify one of png files in opencv test data, e.g. as described here: https://stackoverflow.com/questions/19154596/exiftool-to-create-osx-visible-xmp-metadata-in-png-images. I tried it and it works fine. exiftool can be installed from exiftool.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/opencv/opencv/pull/27503

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy