| 507 | //! @endcond |
| 508 | |
| 509 | WriteMethod ExifParser::encode(Blob& blob, const byte* pData, size_t size, ByteOrder byteOrder, ExifData& exifData) { |
| 510 | // Delete IFD0 tags that are "not recorded" in compressed images |
| 511 | // Reference: Exif 2.2 specs, 4.6.8 Tag Support Levels, section A |
| 512 | static constexpr auto filteredIfd0Tags = std::array{ |
| 513 | "Exif.Image.PhotometricInterpretation", |
| 514 | "Exif.Image.StripOffsets", |
| 515 | "Exif.Image.RowsPerStrip", |
| 516 | "Exif.Image.StripByteCounts", |
| 517 | "Exif.Image.JPEGInterchangeFormat", |
| 518 | "Exif.Image.JPEGInterchangeFormatLength", |
| 519 | "Exif.Image.SubIFDs", |
| 520 | // Issue 981. Never allow manufactured data to be written |
| 521 | "Exif.Canon.AFInfoSize", |
| 522 | "Exif.Canon.AFAreaMode", |
| 523 | "Exif.Canon.AFNumPoints", |
| 524 | "Exif.Canon.AFValidPoints", |
| 525 | "Exif.Canon.AFCanonImageWidth", |
| 526 | "Exif.Canon.AFCanonImageHeight", |
| 527 | "Exif.Canon.AFImageWidth", |
| 528 | "Exif.Canon.AFImageHeight", |
| 529 | "Exif.Canon.AFAreaWidths", |
| 530 | "Exif.Canon.AFAreaHeights", |
| 531 | "Exif.Canon.AFXPositions", |
| 532 | "Exif.Canon.AFYPositions", |
| 533 | "Exif.Canon.AFPointsInFocus", |
| 534 | "Exif.Canon.AFPointsSelected", |
| 535 | "Exif.Canon.AFPointsUnusable", |
| 536 | "Exif.Canon.AFFineRotation", |
| 537 | }; |
| 538 | for (auto&& filteredIfd0Tag : filteredIfd0Tags) { |
| 539 | auto pos = exifData.findKey(ExifKey(filteredIfd0Tag)); |
| 540 | if (pos != exifData.end()) { |
| 541 | #ifdef EXIV2_DEBUG_MESSAGES |
| 542 | std::cerr << "Warning: Exif tag " << pos->key() << " not encoded\n"; |
| 543 | #endif |
| 544 | exifData.erase(pos); |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | // Delete IFDs which do not occur in JPEGs |
| 549 | static constexpr auto filteredIfds = std::array{ |
| 550 | IfdId::subImage1Id, IfdId::subImage2Id, IfdId::subImage3Id, IfdId::subImage4Id, IfdId::subImage5Id, |
| 551 | IfdId::subImage6Id, IfdId::subImage7Id, IfdId::subImage8Id, IfdId::subImage9Id, IfdId::subThumb1Id, |
| 552 | IfdId::panaRawId, IfdId::ifd2Id, IfdId::ifd3Id, |
| 553 | }; |
| 554 | for (auto&& filteredIfd : filteredIfds) { |
| 555 | #ifdef EXIV2_DEBUG_MESSAGES |
| 556 | std::cerr << "Warning: Exif IFD " << filteredIfd << " not encoded\n"; |
| 557 | #endif |
| 558 | eraseIfd(exifData, filteredIfd); |
| 559 | } |
| 560 | |
| 561 | // IPTC and XMP are stored elsewhere, not in the Exif APP1 segment. |
| 562 | IptcData emptyIptc; |
| 563 | XmpData emptyXmp; |
| 564 | |
| 565 | // Encode and check if the result fits into a JPEG Exif APP1 segment |
| 566 | MemIo mio1; |
nothing calls this directly
no test coverage detected