I want to replace the JPG preview image in a my camera's RAW files with the camera's JPG (I shoot JPG + RAW). I'm using a Panasonic GH1, so the RAW format is RW2. After having finally figured how the RW2 file is organized, I noticed that exiftool can do exactly what I want.
However, I noticed that the JPG preview image embedded in an RW2 always has some data trailing the EOI marker (0xFFD9). Here's a dump (0xFFD9 is at the end of the first line):
0059680: c315 1b0e 5b19 f7a6 f662 d6f2 d4ff d9ff ....[....b......
0059690: ffff ffff ffff ffff ffff ffff ffff ffff ................
00596a0: 9290 9192 9392 9093 9795 9293 9494 9494 ................
00596b0: 9494 9493 9192 9392 9293 9395 9694 9596 ................
00596c0: 9292 9394 9697 9491 9194 9394 9493 9394 ................
00596d0: 9493 9494 9393 9494 9493 9291 9294 9394 ................
00596e0: 9596 9492 9695 9193 9696 9595 9694 9493 ................
00596f0: 9394 9494 9595 9493 9394 9494 9494 9495 ................
0059700: 9694 9695 9394 9595 9595 9294 9794 9294 ................
0059710: 9595 9393 9596 9694 9294 9593 9697 9493 ................
0059720: 9493 9394 9696 9696 9596 9593 9494 9393 ................
0059730: 9292 9494 9393 9190 938f 7f6a 4935 333d ...........jI53=
0059740: 5b75 7877 8892 9393 9190 9192 9495 9595 [uxw............
0059750: 9393 9493 9494 9493 9394 9595 9494 9696 ................
0059760: 9494 9697 9695 9493 9293 9492 9496 9595 ................
0059770: 9495 9393 9391 9194 9594 9494 9494 9394 ................
0059780: 9795 9798 9495 9899 9998 9696 9594 9694 ................
0059790: 9193 9695 9394 9593 9394 9491 908d 7753 ..............wS
00597a0: 3737 567b 8c92 9595 9292 9495 9493 9495 77V{............
00597b0: 9594 9496 9695 9697 9694 9597 9796 9796 ................
00597c0: 9594 9496 9792 9194 9393 9393 9497 9a98 ................
00597d0: 9592 9395 9595 9695 9597 9695 9597 9794 ................
00597e0: 9394 9493 9595 9495 9694 9397 9795 9698 ................
00597f0: 9392 9494 9393 9596 9695 9494 9593 9294 ................
Should I be worried about removing these bytes (some 400) from the RW2 file? Or is it merely a bunch of meaningless data that is there due to how the hardware in the GH1 works? Looking at a number of RW2 files, I noticed that the next data block following these bytes always starts at an offset that is a multiple of 256. This seems to support the latter guess.