Пример #1
0
    def test_export_load(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        image_download = self.oo.get_image('kasthuri11', 'image',
                                           1000, 1100,
                                           1000, 1100,
                                           1000,
                                           resolution=3)

        # if returns string, successful export
        self.assertEqual(
                         ndtiff.save("tests/trash/download-1.tiff",
                                     image_download),
                         "tests/trash/download-1.tiff")

        # now confirm import works too
        self.assertEqual(
                         ndtiff.load("tests/trash/download-1.tiff")[0][0],
                         image_download[0][0])
        self.assertEqual(
                         ndtiff.load("tests/trash/download-1.tiff")[10][10],
                         image_download[10][10])
Пример #2
0
    def identify_imagesize(self, image_type, image_path='/tmp/img.'):
        """
        Identify the image size using the data location and other parameters
        """
        dims = ()
        try:
            if (image_type.lower() == 'png'):
                dims = np.shape(ndpng.load('{}{}'.format(
                    image_path, image_type
                )))
            elif (image_type.lower() == 'tif' or image_type.lower() == 'tiff'):
                dims = np.shape(ndtiff.load('{}{}'.format(
                    image_path, image_type
                )))

            else:
                raise ValueError("Unsupported image type.")
        except:
            raise OSError('The file was not accessible at {}{}'.format(
                image_path,
                image_type
            ))
        return dims[::-1]
Пример #3
0
    def identify_imagesize(self, image_type, image_path='/tmp/img.'):
        """
        Identify the image size using the data location and other parameters
        """
        dims = ()
        try:
            if (image_type.lower() == 'png'):
                dims = np.shape(ndpng.load('{}{}'.format(
                    image_path, image_type
                )))
            elif (image_type.lower() == 'tif' or image_type.lower() == 'tiff'):
                dims = np.shape(ndtiff.load('{}{}'.format(
                    image_path, image_type
                )))

            else:
                raise ValueError("Unsupported image type.")
        except:
            raise OSError('The file was not accessible at {}{}'.format(
                image_path,
                image_type
            ))
        return dims[::-1]