gm will modify streaming data even in cases when the function is not intended to
I think this is an odd consequence of how the gm module invokes the gm binary for these cases.
I made a few test cases: The streaming case pipes to the gm module to get image size, and then pipes the (theoretically unmodified) output to disk. The buffer case passes a full buffer to gm, and then writes the original buffer back to disk.
So check this logging out:
Running streaming version: