How to use the trollimage.image.UnknownImageFormat function in trollimage

To help you get started, we’ve selected a few trollimage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytroll / mpop / mpop / imageo / geo_image.py View on Github external
if fformat.lower() in ('tif', 'tiff'):
            kwargs = kwargs or {}
            kwargs['writer_options'] = writer_options
            return self.geotiff_save(filename, compression, tags,
                                     gdal_options, blocksize,
                                     **kwargs)
        try:
            # Let image.pil_save it ?
            Image.save(self, filename, compression, fformat=fformat)
        except UnknownImageFormat:
            # No ... last resort, try to import an external module.
            logger.info("Importing image writer module '%s'" % fformat)
            try:
                saver = __import__(fformat, globals(), locals(), ['save'])
            except ImportError:
                raise UnknownImageFormat(
                    "Unknown image format '%s'" % fformat)
            kwargs = kwargs or {}
            kwargs['writer_options'] = writer_options
            saver.save(self, filename, **kwargs)
github pytroll / satpy / satpy / imageo / geo_image.py View on Github external
file_tuple = os.path.splitext(filename)
        fformat = fformat or file_tuple[1][1:]

        if fformat.lower() in ('tif', 'tiff'):
            return self.geotiff_save(filename, compression, tags,
                                     gdal_options, blocksize, **kwargs)
        try:
            # Let image.pil_save it ?
            Image.save(self, filename, compression, fformat=fformat)
        except UnknownImageFormat:
            # No ... last resort, try to import an external module.
            logger.info("Importing image writer module '%s'" % fformat)
            try:
                saver = __import__(fformat, globals(), locals(), ['save'])
            except ImportError:
                raise UnknownImageFormat(
                    "Unknown image format '%s'" % fformat)
            saver.save(self, filename, **kwargs)