Search code examples
pythonpython-3.ximage-processingscikit-image

Convert png to jpeg using scikit-image


I'm new to scikit-image and image processing and trying to convert png image to jpeg. But my misfortune was that I couldn't find a way nor documentation. I want to convert it only using scikit, I have already tried pillow and succeed. Can anyone help me?


Solution

  • It's not clear to me why exactly you are asking this or what are you trying to achieve but but as far as I know scikit uses plugins to read and write images. Check this page that provides a summary of the available plugins for example.

    You can check the plugin available using:

    import skimage.io as io
    io.find_available_plugins()
    

    (in my case)

    {'fits': ['imread', 'imread_collection'], 'gdal': ['imread', 'imread_collection'], 'gtk': ['imshow'], 'imageio': ['imread', 'imsave', 'imread_collection'], 'imread': ['imread', 'imsave', 'imread_collection'], 'matplotlib': ['imshow', 'imread', 'imshow_collection', 'imread_collection'], 'pil': ['imread', 'imsave', 'imread_collection'], 'qt': ['imshow', 'imsave', 'imread', 'imread_collection'], 'simpleitk': ['imread', 'imsave', 'imread_collection'], 'tifffile': ['imread', 'imsave', 'imread_collection']}

    and the loaded ones with:

    io.find_available_plugins(loaded=True)
    

    (in my case)

    {'matplotlib': ['imshow', 'imread', 'imshow_collection', 'imread_collection'], 'pil': ['imread', 'imsave', 'imread_collection']}

    You can load a plugin:

    import skimage.io as io
    io.use_plugin('pil')
    

    or a specific module:

    io.use_plugin('pil', 'imread') # Use only the imread capability of PIL
    

    So, you can choose which plugin to use. In either case it's not pure skikit of course. Extended information can be found here (most commands where taken from here).