Esempio n. 1
0
def testConverterMainFullStats(tmpdir):
    imagePath = datastore.fetch('sample_Easy1.png')
    outputPath = os.path.join(tmpdir, 'out.tiff')
    main.main([imagePath, outputPath, '--full-stats'])
    info = tifftools.read_tiff(outputPath)
    desc = json.loads(info['ifds'][0]['tags'][tifftools.Tag.ImageDescription.value]['data'])
    assert 'psnr' in desc['large_image_converter']['conversion_stats']
Esempio n. 2
0
def testConverterMainNonImageFile(tmpdir):
    testDir = os.path.dirname(os.path.realpath(__file__))
    imagePath = os.path.join(testDir, 'test_files', 'notanimage.txt')
    outputPath = os.path.join(tmpdir, 'out.tiff')
    with pytest.raises(Exception):
        main.main([imagePath, outputPath])
    assert not os.path.exists(outputPath)
Esempio n. 3
0
def testConverterMainFullStatsWithWebp(tmpdir):
    imagePath = datastore.fetch('d042-353.crop.small.float32.tif')
    outputPath = os.path.join(tmpdir, 'out.tiff')
    main.main([imagePath, outputPath, '--compression', 'webp', '--full-stats'])
    info = tifftools.read_tiff(outputPath)
    desc = json.loads(info['ifds'][0]['tags'][tifftools.Tag.ImageDescription.value]['data'])
    assert 'psnr' in desc['large_image_converter']['conversion_stats']
    assert desc['large_image_converter']['conversion_stats']['psnr'] < 60
Esempio n. 4
0
def testConverterMainStats(tmpdir):
    testDir = os.path.dirname(os.path.realpath(__file__))
    imagePath = os.path.join(testDir, 'test_files', 'yb10kx5k.png')
    outputPath = os.path.join(tmpdir, 'out.tiff')
    main.main([imagePath, outputPath, '--stats'])
    info = tifftools.read_tiff(outputPath)
    desc = json.loads(info['ifds'][0]['tags'][tifftools.Tag.ImageDescription.value]['data'])
    assert 'conversion_stats' in desc['large_image_converter']
Esempio n. 5
0
def testConverterMain(tmpdir):
    testDir = os.path.dirname(os.path.realpath(__file__))
    imagePath = os.path.join(testDir, 'test_files', 'yb10kx5k.png')
    outputPath = os.path.join(tmpdir, 'out.tiff')
    main.main([imagePath, outputPath])
    assert os.path.getsize(outputPath) > 100

    outputPath2 = os.path.join(tmpdir, 'out2.tiff')
    main.main([imagePath, outputPath2, '--compression', 'zip'])
    assert os.path.getsize(outputPath2) > 100
    assert os.path.getsize(outputPath2) < os.path.getsize(outputPath)
Esempio n. 6
0
def testConverterMainConcurrency(tmpdir):
    imagePath = datastore.fetch('sample.ome.tif')
    outputPath = os.path.join(tmpdir, 'out.tiff')
    main.main([imagePath, outputPath, '--concurrency', '2'])
    assert os.path.getsize(outputPath) > 100
Esempio n. 7
0
def testConverterMainNonFile(tmpdir):
    outputPath = os.path.join(tmpdir, 'out.tiff')
    assert main.main(['not a file', outputPath]) == 1