In the case where a JPEG file must be edited, but without leaving the file "apparently" edited (i.e. leaving all metadata, spec-/format-ambiguities, DCT tables, etc., byte-identical to the original), do any tools currently exist for packing/unpacking raw sectors without modifying more bytes than strictly necessary (relative to the original file)?
In particular, it's my understanding that the run-length coding used for compression will render a hex editor infeasible for this task — if it weren't for that, that'd be the tool for this job. And no conventional image editor will even approximately minimize e.g. the Hamming distance between the original and re-saved file, which is a pretty-accurate proxy for what I'm requesting here.
I'm aware that there are other forensic considerations, in addition to mere visual "plausibility" of the edits, both out-of-scope of this question. The scope of this question is specifically about editing the file without leaving forensically noticeable changes to its structure.