Skip to content

Commit

Permalink
Merge pull request #56 from pushd/no_exif
Browse files Browse the repository at this point in the history
Complete conversion (with warning) even if EXIF data is missing.
  • Loading branch information
Adrian Liechti authored Sep 15, 2019
2 parents f6e96a5 + 806b699 commit 74bb2a5
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/heif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,28 @@ DataVector extractExifData(HevcImageFileReader* reader, uint32_t contextId, uint
{
IdVector exifItemIds;
DataVector exifData;
DataVector result;

reader->getReferencedToItemListByType(contextId, itemId, "cdsc", exifItemIds);

if (exifItemIds.empty()) {
throw logic_error("Exif Data ID (cdsc) not found!");
}

reader->getItemData(contextId, exifItemIds.at(0), exifData);

if (exifData.empty()) {
throw logic_error("Exif data is empty");
}

int exifOffset = findExifHeaderOffset(exifData);
if (exifOffset == -1) {
throw logic_error("Exif data not found");
cerr << "Warning: Exif Data ID (cdsc) not found!\n";
} else {
reader->getItemData(contextId, exifItemIds.at(0), exifData);

if (exifData.empty()) {
cerr << "Warning: Exif data is empty\n";
} else {
int exifOffset = findExifHeaderOffset(exifData);

if (exifOffset == -1) {
cerr << "Warning: Exif data not found\n";
} else {
uint64_t skipBytes = static_cast<uint64_t>(exifOffset);
result.insert(result.begin(), exifData.begin() + skipBytes, exifData.end() - exifOffset);
}
}
}

DataVector result;
uint64_t skipBytes = static_cast<uint64_t>(exifOffset);
result.insert(result.begin(), exifData.begin() + skipBytes, exifData.end() - exifOffset);
return result;
}

Expand Down

0 comments on commit 74bb2a5

Please sign in to comment.