-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
[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
base: 4.x
Are you sure you want to change the base?
Conversation
modules/imgcodecs/src/grfmt_png.cpp
Outdated
@@ -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, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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/
There was a problem hiding this comment.
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.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.