Lymphatus / CaesiumPH

Lossless JPEG compression for photographers and webmasters
http://saerasoft.com/caesium/ph
GNU General Public License v3.0
90 stars 11 forks source link

Added option to keep all EXIF data #22

Open hkolvenbach opened 4 years ago

hkolvenbach commented 4 years ago

This fixes issue #21 by adding another option to keep all EXIF data which was present in the source file.

I just added another checkbox to the compression preferences dialog to keep it simple.

Screen Shot 2020-04-20 at 20 22 20

If Keep all EXIF data is checked, the whole set of EXIF data is copied at once to the new picture. I added a function void writeAllExifTags(Exiv2::ExifData exifData, QString imagePath); to accomplish that by copying the exifData object.

Note: I added an import #include <iostream> to exif.cpp, because otherwise std::cout couldn't be found (Mac OS X 10.15.4, Apple clang version 11.0.3 (clang-1103.0.32.29)).

Lymphatus commented 4 years ago

Hi! The first option "Keep EXIF information" was meant to copy all the possible metadata, which is what you're trying to do. I don't think we need a new checkbox, but to fix the behaviour of the first one.

hkolvenbach commented 4 years ago

Hi @Lymphatus! I wasn't sure if it was meant to do that when all checkboxes are set, so I added another one.

I've uploaded a new version which behaves as you describe, e.g. if all checkboxes are set, it will copy all EXIF information. I added a constant MAX_EXIF_ENTRIES for the length of the enum cexifs. If there are more checkboxes added in the future, this constant needs to be increased manually. There are ways to automatically count the entries of the enum (https://stackoverflow.com/questions/2102582/how-can-i-count-the-items-in-an-enum) but they did look quite cumbersome in C++ < 17.

There is one implication of this approach though: The user is not able to only keep the EXIF information of copyright, date AND comments, it will always copy all EXIF data in that case. If the user selects only 2 of the 3, it will only copy those.

Lymphatus commented 4 years ago

Oh you're right. I think the best approach could be something like:

Checking the first one would copy all the EXIFs and the Other means "All other data except from Copyright, Date, Comments". So the following issue sould be solved.

The user is not able to only keep the EXIF information of copyright, date AND comments, it will always copy all EXIF data in that case. If the user selects only 2 of the 3, it will only copy those.

What do you think?

hkolvenbach commented 4 years ago

Sounds good, but makes it a bit more complicated ;-) Right know I just copy the whole EXIF header when "Other" is selected, so in the case that one of the first 3 options is deselected, we would either need to iterate through all options and copy all except the ones not selected or copy everything and delete the entries that weren't selected afterwards.

Another idea would be to have option buttons choose:

I am open for both approaches, whatever you like best.