timholy/Images.jl — pull request #55 by lucasb-eyer (2013-12-19 22:00:40+00:00)
Title: Fix #53 and some

Finally figured it out. `imread(::String)` wasn't closing the stream it opened! I verified my solution (4934a81) using `lsof -c julia` and all file handles are indeed closed.

In the same run, I:
- changed all `stream = open(...)` to `open(...) do stream` which should be safer when exceptions occur.
- made `imwrite(.., ::String, ::Type{PPMBinary})` close the file it opens, and `imwrite(.., ::IO, ::Type{PPMBinary})` not close it, since it hasn't opened it and the caller doesn't expect that to happen!
- removed unnecessary `magicbuf` and allocate id large enough instead of growing it.

I think `src/ioformats/nrrd.jl` lines 57 and 59 do open streams which are never closed. I didn't touch that code since I have no clue about that fileformat and thus wouldn't even be able to test it. Just letting you know.