LeoHsiao1 / pyexiv2

Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.
GNU General Public License v3.0
201 stars 39 forks source link

Handling clear/set/get of JPEG header comment via libexiv2 #40

Closed dgtlmoon closed 3 years ago

dgtlmoon commented 3 years ago

As well supported by the libexiv2-dev interface, support for the JPEG Header comment field, technically this is also metadata :+1:

I'm testing/building like this on Ubuntu/Debian, python3.6

cd pyexiv2/lib/
g++ exiv2api.cpp -o py36-linux/exiv2api.so -O3 -Wall -std=c++11 -shared -fPIC `python3 -m pybind11 --includes` -I /usr/include/exiv2 -I /usr/include/python3 -L ./lib -l exiv2
cd ../..
python3 setup.py install
pytest -v
LeoHsiao1 commented 3 years ago

Thank you for all your work. I found the code for Comment in EXIV2, but I wasn't sure it belonged to JPEG Comment. Are you in a hurry to implement this feature? I'd like to wait until the New Year holidays to add this feature.

LeoHsiao1 commented 3 years ago

In addition, please submit this PR to the dev branch. I will merge it into the master branch after all the platforms and all the Python versions have been tested.

dgtlmoon commented 3 years ago

Maybe a better idea is to have the comment available as an attribute of Image, instead of get_comment() ?

dgtlmoon commented 3 years ago

Nearly everyone does not realise that JPEG Header comment != EXIF Comment.... It is also the responsilbity of any documentation to make sure the user knows this.

Making these kinds of issues very well documented and easy to manage by the programmer through your library is what makes libraries very popular and live a long time with many good contributors.

Slightly better documentation can save people months of heart-ache when they realise some information is there that should not be, or they think it's a bug

So in this case, it can lead to leaking information, personal data, identifying information, etc.. super important to have this I think, maybe another idea can be to have a

In the future, on another pull request - self.img.clear_all_metadata() that clears

an idea..

LeoHsiao1 commented 3 years ago

Oh, I also wrote an API called img.clear_all() before. But I later realized that the meaning of all was ambiguous, and that there were dozens of standards for metadata, of which I could only delete EXIF, IPTC and XMP. So I removed the API.

LeoHsiao1 commented 3 years ago

As you can see from the ExifTool documentation, there are too many types of image metadata. Exiv2 mainly supports three kinds of metadata: EXIF, IPTC and XMP. People often only care about what kind of image metadata they see on their phones and computers. For example, when I looked at your previous photo using the professional software Adobe Bridge, the metadata displayed was empty, so I thought there was no metadata on the image.

dgtlmoon commented 3 years ago

Oh, I also wrote an API called img.clear_all() before. But I later realized that the meaning of all was ambiguous, and that there were dozens of standards for metadata, of which I could only delete EXIF, IPTC and XMP. So I removed the API.

Yeah ok, agreed, well, in 99% of cases just using the existing libexiv2 functionality for handling comments would be really wonderful, looking forwards to seeing this pull request merged..

dgtlmoon commented 3 years ago

@LeoHsiao1 Please remove Can't read/write image structure which is not metadata, such as JPEG Comment from the README.md ...

LeoHsiao1 commented 3 years ago

Oh, I'll update the document after I merge this PR into the master branch.

LeoHsiao1 commented 3 years ago

I've written the API for JPEG Comment and I'm writing the test case now. I will also check the ability to read and write ICC profile in the image, so I cannot release a new version today.

dgtlmoon commented 3 years ago

@LeoHsiao1 You've completely confused me again - there is already def test_modify_jpeg_header_comments(): ... ?

dgtlmoon commented 3 years ago

Are you using the actual code from peoples pull requests or are you just rewriting it entirely??

LeoHsiao1 commented 3 years ago

Although you have done most of the work, there is still something to be done. For example:

dgtlmoon commented 3 years ago

@LeoHsiao1 I've written the API for JPEG Comment and I'm writing the test case now. ... I'm completely confused! I've already written this as part of this pull request !?!?!?

dgtlmoon commented 3 years ago

OK! Got it, sorry man, If you add a little more information in your comments it helps a lot! thanks again

LeoHsiao1 commented 3 years ago

Thank you for your work. It was only during the test that I found your code needed to be modified. I just found out that I can add Comment to a PNG image, but I can't see it with exifTool.

github-actions[bot] commented 3 years ago

This pull request has been automatically closed because there has been no activity for a month.