Esempio n. 1
0
def create_sprite(config, df):

    images_array = [
        Tools.read_np_picture(os.path.join(
            config.get('directory')['collections'], "%s.jpg" % picture_id),
                              target_size=(TARGET_SIZE_HEIGHT,
                                           TARGET_SIZE_WIDTH))
        for picture_id in df['pictures_id']
    ]
    sprite = np.zeros((TARGET_SIZE_HEIGHT * SPRITE_NB_LIGNE,
                       TARGET_SIZE_WIDTH * SPRITE_NB_COLONNE, 3))
    index = 0
    for i in range(SPRITE_NB_LIGNE):
        for j in range(SPRITE_NB_COLONNE):
            sprite[(i * TARGET_SIZE_HEIGHT):(i + 1) * TARGET_SIZE_HEIGHT,
                   (j * TARGET_SIZE_WIDTH):(j + 1) *
                   TARGET_SIZE_WIDTH, :] = images_array[index]
            index += 1
            if index >= len(images_array):
                break
        if index >= len(images_array):
            break

    img = Tools.display_one_picture(sprite)
    return img
Esempio n. 2
0
def write_poster_picture(config, poster_config, poster, poster_id=None):

    poster_id = poster_id if poster_id else uuid.uuid1()
    img = Tools.display_one_picture(poster)
    img.save(
        os.path.join(
            CONFIG.get('directory')['data_dir'], 'posters',
            "version_%s_%s.jpg" % (poster_config['version'], poster_id)),
        "JPEG")

    return poster_id