metadata: preserve standard exif tags (accidentally broken by 7310eb64978bb1138edbdf02fa58fb64a9326e17)
(cherry picked from commit 75a49b8cb9db957dfe13e6911dcf6c83bb92045d)
This commit is contained in:
committed by
Lawrence Lee
parent
c1719fbd7d
commit
9735ba5768
@@ -22,6 +22,7 @@
|
||||
#include <glib/gstdio.h>
|
||||
#include <iostream>
|
||||
#include <giomm.h>
|
||||
#include <set>
|
||||
|
||||
#include "metadata.h"
|
||||
#include "settings.h"
|
||||
@@ -243,22 +244,87 @@ void Exiv2Metadata::remove_unwanted(Exiv2::ExifData &dst) const
|
||||
Exiv2::ExifThumb thumb(dst);
|
||||
thumb.erase();
|
||||
|
||||
static const std::set<std::string> badtags = {
|
||||
"Exif.Image.Orientation",
|
||||
"Exif.Image2.JPEGInterchangeFormat",
|
||||
"Exif.Image2.JPEGInterchangeFormatLength",
|
||||
"Exif.Image.NewSubfileType",
|
||||
"Exif.Image.SubfileType",
|
||||
"Exif.Image.ImageWidth",
|
||||
"Exif.Image.ImageLength",
|
||||
"Exif.Image.BitsPerSample",
|
||||
"Exif.Image.Compression",
|
||||
"Exif.Image.PhotometricInterpretation",
|
||||
"Exif.Image.Thresholding",
|
||||
"Exif.Image.CellWidth",
|
||||
"Exif.Image.CellLength",
|
||||
"Exif.Image.FillOrder",
|
||||
"Exif.Image.StripOffsets",
|
||||
"Exif.Image.Orientation",
|
||||
"Exif.Image.SamplesPerPixel",
|
||||
"Exif.Image.RowsPerStrip",
|
||||
"Exif.Image.StripByteCounts",
|
||||
"Exif.Image.XResolution",
|
||||
"Exif.Image.YResolution",
|
||||
"Exif.Image.PlanarConfiguration",
|
||||
"Exif.Image.GrayResponseUnit",
|
||||
"Exif.Image.GrayResponseCurve",
|
||||
"Exif.Image.T4Options",
|
||||
"Exif.Image.T6Options",
|
||||
"Exif.Image.ResolutionUnit",
|
||||
"Exif.Image.PageNumber",
|
||||
"Exif.Image.Predictor",
|
||||
"Exif.Image.TileWidth",
|
||||
"Exif.Image.TileLength",
|
||||
"Exif.Image.TileOffsets",
|
||||
"Exif.Image.TileByteCounts",
|
||||
"Exif.Image.SubIFDs",
|
||||
"Exif.Image.ExtraSamples",
|
||||
"Exif.Image.SampleFormat",
|
||||
"Exif.Image.SMinSampleValue",
|
||||
"Exif.Image.SMaxSampleValue",
|
||||
"Exif.Image.Indexed",
|
||||
"Exif.Image.JPEGTables",
|
||||
"Exif.Image.OPIProxy",
|
||||
"Exif.Image.JPEGProc",
|
||||
"Exif.Image.JPEGInterchangeFormat",
|
||||
"Exif.Image.JPEGInterchangeFormatLength",
|
||||
"Exif.Image.JPEGRestartInterval",
|
||||
"Exif.Image.JPEGLosslessPredictors",
|
||||
"Exif.Image.JPEGPointTransforms",
|
||||
"Exif.Image.JPEGQTables",
|
||||
"Exif.Image.JPEGDCTables",
|
||||
"Exif.Image.JPEGACTables",
|
||||
"Exif.Image.TIFFEPStandardID",
|
||||
"Exif.Image.DNGVersion",
|
||||
"Exif.Image.DNGBackwardVersion",
|
||||
"Exif.Image.DNGPrivateData",
|
||||
"Exif.Image.OriginalRawFileData",
|
||||
"Exif.Image.SubTileBlockSize",
|
||||
"Exif.Image.RowInterleaveFactor",
|
||||
"Exif.Photo.ComponentsConfiguration",
|
||||
"Exif.Photo.CompressedBitsPerPixel"
|
||||
};
|
||||
|
||||
static const std::vector<std::string> badpatterns = {
|
||||
"Exif.Image.",
|
||||
"Exif.SubImage"
|
||||
};
|
||||
|
||||
for (auto it = dst.begin(); it != dst.end(); ) {
|
||||
bool found = false;
|
||||
for (auto &p : badpatterns) {
|
||||
if (it->key().find(p) == 0) {
|
||||
it = dst.erase(it);
|
||||
found = true;
|
||||
break;
|
||||
if (badtags.find(it->key()) != badtags.end()) {
|
||||
it = dst.erase(it);
|
||||
} else {
|
||||
bool found = false;
|
||||
for (auto &p : badpatterns) {
|
||||
if (it->key().find(p) == 0) {
|
||||
it = dst.erase(it);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user