File object support for imread and imsave #3124

Merged
merged 2 commits into from Feb 24, 2014

Projects

None yet

4 participants

@jleinonen

Made changes to image reading and writing routines to support file objects properly. Actually scipy.misc.imread didn't have to be changed because PIL already supports file objects, but I changed the docstring to say explicitly that it supports them. I made similar changes to scipy.ndimage.misc.imread, though I'm not quite sure why that can't just import from scipy.misc.

@coveralls

Coverage Status

Coverage remained the same when pulling f63f3aa on jleinonen:master into 5739a8b on scipy:master.

@rgommers
Member

Thanks for the fix. I'll try to have a closer look at this in a few days.

It's indeed ugly that we have two imread functions. We should take over the latest fixes that were made to this function in scikit-image and deprecate misc.imread.

@rgommers
Member
rgommers commented Feb 2, 2014

OK I'm not going to get around to reworking the misc module any time soon. So we should merge this PR.

@rgommers rgommers commented on an outdated diff Feb 2, 2014
scipy/misc/pilutil.py
@@ -100,21 +100,21 @@ def bytescale(data, cmin=None, cmax=None, high=255, low=0):
return cast[uint8](bytedata) + cast[uint8](low)
-def imread(name,flatten=0):
+def imread(imfile, flatten=0):
@rgommers
rgommers Feb 2, 2014 SciPy member

This is actually a backwards compatibility break, because you can use positional arguments like kwargs (like imread(name='fname.png')). So can you undo this change?

@rgommers
Member
rgommers commented Feb 2, 2014

Can you add a test for the functionality you add here to ndimage/tests/test_io.py?

@rgommers
Member
rgommers commented Feb 2, 2014

With a test and undoing the rename this should be good to go.

@jleinonen

Finally got around to make these changes.

@coveralls

Coverage Status

Coverage remained the same when pulling 60a43ae on jleinonen:master into 5739a8b on scipy:master.

@pv pv merged commit 60a43ae into scipy:master Feb 24, 2014

1 check passed

Details default The Travis CI build passed
@pv
Member
pv commented Feb 24, 2014

Thanks, merged.

@pv pv added this to the 0.14.0 milestone Feb 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment