コード例 #1
0
ファイル: test_tiff.py プロジェクト: quintusdias/allerlei
 def test_xmp(self):
     data = np.zeros((256, 256, 3), dtype=np.uint8)
     with tempfile.NamedTemporaryFile(suffix=".tif") as tfile:
         with TIFF.open(tfile.name, 'w') as tifp:
             TIFF.setfield(tifp, 'ImageWidth', 256)
             TIFF.setfield(tifp, 'ImageLength', 256)
             TIFF.setfield(tifp, 'RowsPerStrip', 256)
             TIFF.setfield(tifp, 'SamplesPerPixel', 3)
             TIFF.setfield(tifp, 'BitsPerSample', 8)
             TIFF.setfield(tifp, 'PlanarConfiguration', TIFF.PLANARCONFIG_CONTIG)
             TIFF.setfield(tifp, 'PhotometricInterpretation', TIFF.PHOTOMETRIC_RGB)
             TIFF.setfield(tifp, 'SampleFormat', TIFF.SAMPLEFORMAT_IEEEFP)
             TIFF.setfield(tifp, 'XMLPacket', 'This is a test')
             TIFF.writeencodedstrip(tifp, 0, data)
         import shutil
         shutil.copyfile(tfile.name,
                         os.path.join(os.environ['HOME'], 'b.tif'))
コード例 #2
0
ファイル: test_hotdog.py プロジェクト: quintusdias/allerlei
    def test_basic(self):
        with SD.start(self.sdfile, SD.DFACC_READ) as sdid:
            idx = SD.nametoindex(sdid, 'Reflectivity')
            with SD.select(sdid, idx) as sds_id:
                data = SD.readdata(sds_id)

        nrows, ncols = data.shape
        with tempfile.NamedTemporaryFile(suffix=".tif") as tfile:
            with TIFF.open(tfile.name, 'w') as tifp:
                TIFF.setfield(tifp, 'ImageWidth', ncols)
                TIFF.setfield(tifp, 'ImageLength', nrows)
                TIFF.setfield(tifp, 'SamplesPerPixel', 1)
                TIFF.setfield(tifp, 'BitsPerSample', 32)
                TIFF.setfield(tifp, 'PlanarConfiguration', TIFF.PLANARCONFIG_CONTIG)
                TIFF.setfield(tifp, 'PhotometricInterpretation', TIFF.PHOTOMETRIC_MINISBLACK)
                TIFF.setfield(tifp, 'SampleFormat', TIFF.SAMPLEFORMAT_IEEEFP)
                TIFF.setfield(tifp, 'RowsPerStrip', nrows)
                TIFF.writeencodedstrip(tifp, 0, data)
            import shutil
            shutil.copyfile(tfile.name,
                            os.path.join(os.environ['HOME'], 'b.tif'))