Example #1
0
def test_convert_to_jpeg():
    """ test convert_to_jpeg """
    import pathlib
    import tempfile
    from osxphotos.fileutil import FileUtil

    temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
    with temp_dir:
        imgfile = pathlib.Path(TEST_HEIC)
        outfile = pathlib.Path(temp_dir.name) / f"{imgfile.stem}.jpeg"
        assert FileUtil.convert_to_jpeg(imgfile, outfile)
        assert outfile.is_file()
Example #2
0
def test_convert_to_jpeg_quality():
    """ test convert_to_jpeg with compression_quality """
    import pathlib
    import tempfile
    from osxphotos.fileutil import FileUtil

    temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
    with temp_dir:
        imgfile = pathlib.Path(TEST_RAW)
        outfile = pathlib.Path(temp_dir.name) / f"{imgfile.stem}.jpeg"
        assert FileUtil.convert_to_jpeg(imgfile,
                                        outfile,
                                        compression_quality=0.1)
        assert outfile.is_file()
        assert outfile.stat().st_size < 1000000