More generic/testable resizeAndPipe method