Re: [scikit-image] IO documentation

On Tue, Feb 21, 2017, at 23:38, Stefan van der Walt wrote:
Hi Michael
Apologies, Michal.
On Thu, Jan 5, 2017, at 01:45, Michal Romaniuk wrote:
The IO documentation doesn't seem to be very good. It explains how plugins work but it's scarce on examples e.g. on how to export jpeg image with a specified compression level. The IO API docs don't give much detail either. Some details can be found in the docs for external.tifffile but it takes some searching to find it. For PIL the only way to figure out how to use it seems to be looking at the source code - no modern docs as far as I can tell (did I fail to use Google properly?).
Thanks for your comment; unfortunately io.imsave does not currently support specifying compression level (that is only supported for TIFF files).
That said, you can accomplish this yourself using PIL:
In [1]: from skimage.io._plugins.pil_plugin import ndarray_to_pil
In [2]: from skimage import data
In [3]: img = data.chelsea()
In [4]: pil_img = ndarray_to_pil(img)
In [5]: pil_img.save('/tmp/chelsea0.jpg', quality=10)
In [6]: pil_img.save('/tmp/chelsea1.jpg', quality=90)
In [7]: !du -hcs /tmp/chelsea*.jpg
8.0K /tmp/chelsea0.jpg
36K /tmp/chelsea1.jpg
Best regards
Stéfan
participants (1)
-
Stefan van der Walt