コード例 #1
0
ファイル: test.py プロジェクト: danielballan/photomosaic
def test_roundtrip_pool(pool):
    "save a pool as JSON and reload it"
    tf = tempfile.NamedTemporaryFile()
    pm.export_pool(pool, tf.name)
    pool2 = pm.import_pool(tf.name)
    for (k1, v1), (k2, v2) in zip(sorted(pool.items()), sorted(pool2.items())):
        assert k1 == k2
        assert np.all(v1 == v2)
コード例 #2
0
ファイル: test.py プロジェクト: arasharchor/photomosaic-1
def test_roundtrip_pool(pool):
    "save a pool as JSON and reload it"
    tf = tempfile.NamedTemporaryFile()
    pm.export_pool(pool, tf.name)
    pool2 = pm.import_pool(tf.name)
    for (k1, v1), (k2, v2) in zip(sorted(pool.items()), sorted(pool2.items())):
        assert k1 == k2
        assert np.all(v1 == v2)
コード例 #3
0
ファイル: cats.py プロジェクト: arasharchor/photomosaic-1
import os
import photomosaic.flickr
import photomosaic as pm

if not os.path.isfile(os.path.expanduser('~/pools/cats/pool.json')):
    FLICKR_API_KEY = os.environ['FLICKR_API_KEY']
    pm.set_options(flickr_api_key=FLICKR_API_KEY)

    photomosaic.flickr.from_search('cats', '~/pools/cats/')
    pool = pm.make_pool('~/pools/cats/*.jpg')
    pm.export_pool(
        pool, '~/pools/cats/pool.json')  # save color analysis for future reuse
コード例 #4
0
import os
import photomosaic as pm


POOL_DIR = '/tmp/photomosaic-docs-pool/'
pm.rainbow_of_squares(POOL_DIR)
pool = pm.make_pool(os.path.join(POOL_DIR, '*.png'))
pm.export_pool(pool, os.path.join(POOL_DIR, 'pool.json'))
コード例 #5
0
ファイル: cats.py プロジェクト: danielballan/photomosaic
import os
import photomosaic.flickr
import photomosaic as pm


if not os.path.isfile(os.path.expanduser("~/pools/cats/pool.json")):
    FLICKR_API_KEY = os.environ["FLICKR_API_KEY"]
    pm.set_options(flickr_api_key=FLICKR_API_KEY)

    photomosaic.flickr.from_search("cats", "~/pools/cats/")
    pool = pm.make_pool("~/pools/cats/*.jpg")
    pm.export_pool(pool, "~/pools/cats/pool.json")  # save color analysis for future reuse