MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / writeExifData

Method writeExifData

src/psdimage.cpp:585–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583} // PsdImage::writeIptcData
584
585uint32_t PsdImage::writeExifData(ExifData& exifData, BasicIo& out) {
586 uint32_t resLength = 0;
587 byte buf[8];
588
589 if (!exifData.empty()) {
590 Blob blob;
591 ByteOrder bo = byteOrder();
592 if (bo == invalidByteOrder) {
593 bo = littleEndian;
594 setByteOrder(bo);
595 }
596 ExifParser::encode(blob, bo, exifData);
597
598 if (!blob.empty()) {
599#ifdef EXIV2_DEBUG_MESSAGES
600 std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_ExifInfo << "\n";
601 std::cerr << std::dec << "Writing ExifInfo: size: " << blob.size() << "\n";
602#endif
603 if (out.write(reinterpret_cast<const byte*>(Photoshop::irbId_.front()), 4) != 4)
604 throw Error(ErrorCode::kerImageWriteFailed);
605 us2Data(buf, kPhotoshopResourceID_ExifInfo, bigEndian);
606 if (out.write(buf, 2) != 2)
607 throw Error(ErrorCode::kerImageWriteFailed);
608 us2Data(buf, 0, bigEndian); // NULL resource name
609 if (out.write(buf, 2) != 2)
610 throw Error(ErrorCode::kerImageWriteFailed);
611 ul2Data(buf, static_cast<uint32_t>(blob.size()), bigEndian);
612 if (out.write(buf, 4) != 4)
613 throw Error(ErrorCode::kerImageWriteFailed);
614 // Write encoded Exif data
615 if (out.write(blob.data(), blob.size()) != blob.size())
616 throw Error(ErrorCode::kerImageWriteFailed);
617 resLength += static_cast<long>(blob.size()) + 12;
618 if (blob.size() & 1) // even padding
619 {
620 buf[0] = 0;
621 if (out.write(buf, 1) != 1)
622 throw Error(ErrorCode::kerImageWriteFailed);
623 resLength++;
624 }
625 }
626 }
627 return resLength;
628} // PsdImage::writeExifData
629
630uint32_t PsdImage::writeXmpData(const XmpData& xmpData, BasicIo& out) const {
631 std::string xmpPacket;

Callers

nothing calls this directly

Calls 8

encodeFunction · 0.85
ErrorFunction · 0.85
us2DataFunction · 0.85
ul2DataFunction · 0.85
dataMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected