I’m using skimage to load images from file and save them back to file, and that’s working fine. However, there are times when I’d like to use stdin or stdout so that I don’t have to create intermediate files. Is there some reasonable way to do this within the plugin architecture, or outside of it?
Easiest is to use
imageio. Here is an example script that rotates an image 90 degrees and writes it out as png:
import skimage as ski import sys import io import imageio data = io.BytesIO(sys.stdin.buffer.read()) image = imageio.imread(data) out = ski.transform.rotate(image, 90, resize=True) imageio.imwrite(sys.stdout, out, format='png')
Ah, perfect! Thank you for the example.