user2153235
user2153235

Reputation: 1115

"imagio.imsave" vs "imageio.core.util.Array.tofile"

I am expanding my limited Python knowledge by converting some MATLAB image analysis code to Python. I am following Image manipulation and processing using Numpy and Scipy. The code in Section 2.6.1 saves an image using both imageio.imsave and face.tofile, where type(face)=<class 'imageio.core.util.Array>'.

I am trying to understand why there are two ways to export an image. I tried web-searching tofile, but got numpy.ndarray.tofile. It's very sparse, and doesn't seem to be specific to images. I also looked for imageio.core.util.Array.tofile, but wasn't able to find anything.

Why are there two ways to export files? And why does imageio.core.util.Array.tofile seem to be un-findable online?

Upvotes: 1

Views: 206

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207778

The difference is in what the two functions write in the file.

imageio.imsave() saves a conventional image, like a picture or photo, in JPEG/PNG format that can be viewed with an image viewer like GIMP, feh, eog, Photoshop or MSxPaint.

tofile() saves in a Numpy-compatible format that only Numpy (and a small number of other Python tools) use.

Upvotes: 1

Related Questions