Following up: I published an update to this tool that helps make "bad" rips more square. ImageDisk will create an IMD file that faithfully lacks sectors that it can find no trace of. So reading marginal media that has unreadable and unlocatable sectors will have a track that is perhaps shorter than tracks that came before it because it's lacking unfindable sectors. Worse than that, IMD will decide that's the new norm and stop looking for that sector on later tracks as well (unless you have it analyze every sector which is slow, but at least it improves fidelity in reading marginal media). That's a different problem. For cases where you're missing a sector here or there and the rest of the sectors are fine within tracks, this new option to fill in missing sectors will help.
Recall that the function of IMDU and this tool (imd2raw) is to take a rich IMD image and linearize it into a raw image. That image really needs to be square in order to have it make any sense because there's no metadata anywhere to explain where or why a sector might be missing. So the only reasonable thing to do in this situation is to pad out the missing sector with zeros or xE5s so that subsequent tracks and sectors can be located reliably with consistent offsets. The default behavior is still to be exactly like IMDU was, but the optional –f or --fill-missing parameter will make this change for the output image and indicate missing sectors with a '0' in the graphical display. https://github.com/RetroFloppy/imd2raw
