0

My code compiles fine and the syntax seems fine, but the 50 JPEG files it produces are all empty, except 001.jpg and 019.jpg which both show a small top portion of the image. Could someone kindly tell me why this is happening and help me fix it? Thanks! [code removed to avoid spoiler]

1 Answer 1

1

You seem to be missing a concept. Each jpg will be made up of multiple blocks of 512B. Your goal is to read from the rawfile until you find a signature block. Once you do, if you already have found a jpg, close that one, open a new one, and then write that 512B to the jpg. Then, keep reading/writing until you find the next signature block. Close the jpg, open the next one, write the block, then read/write until you find the next etc etc.

Your code only writes the first 512B block.

1
  • 1
    I can't thank you enough for this. I was focusing so much on the technical aspect that I overlooked a key idea: all the images are back to back, so all the blocks between e.g. signature blocks 'a' and 'b' will solely be blocks for the JPEG file for 'a'. I simply put an 'else' statement to continue copying the blocks after the signature and it worked! What a silly mistake - thank you so much.
    – TronTrix
    Commented Aug 4, 2020 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .