I have a lot of images in my python memory that I would like to place in an in memory tar, after which I would like to flush that tar to the disk.
I would like to do this in memory to prevent the writing of a lot of tiny files to my disk.
What I have so far is a way to save the images as memory files
import imageio
im = np.zeros((256,256))
out_file = io.BytesIO()
imageio.imsave(out_file, im, format = 'jpg')
I can also place these in memory files into an in memory tar.
import tarfile
t = tarfile.TarInfo("helloworld.tif")
t.size = len(out_file.getbuffer())
tarBuffer = io.BytesIO()
tar = tarfile.TarFile(mode="w", fileobj=tarBuffer)
tar.addfile(t, io.BytesIO(out_file.getbuffer()))
But now I do not know how to in turn get this in memory tar file to my disk.
Does anyone have any suggestions how to do this?