Пример #1
0
    def __init__(self, src_img_path, imagebank_path,
                 split_thresh=1200, minsize=10, group_thresh=75, scale=1.0):
        self.src_img_path = src_img_path
        self.imagebank_path = imagebank_path
        self.split_thresh = split_thresh
        self.minsize = minsize
        self.group_thresh = group_thresh

        # load the source image
        self.src_img = Image.open(src_img_path)
        print 'Painter: loaded source image'

        if scale != 1.0:
            width = (int)(self.src_img.size[0] * scale)
            height = (int)(self.src_img.size[1] * scale)
            self.src_img = self.src_img.resize((width, height), Image.ANTIALIAS)
            print 'Painter: scaled source image'

        # Initialize destination image
        self.dest_image = Image.new('RGB', self.src_img.size)
        print 'Painter: initialized destination image'

        # load the image bank
        self.imagebank = ImageBank.open(imagebank_path)

        self.node_groups = None
        self.pic_list = None
Пример #2
0
def main():
    img_bank_dir = path.join(proj_dir, 'Test', 'color_bank')

    imagebank = ImageBank.open(img_bank_dir)

    # remove all image files
    for entry in imagebank.entries:
        img_path = path.join(img_bank_dir, entry.filename)
        os.remove(img_path)
        print 'Deleted %s' % entry.filename

    # remove csv file
    os.remove(path.join(img_bank_dir, ImageBank.IMAGEBANK_CSV_FILENAME))
    print 'Deleted CSV file'
Пример #3
0
    def test_load_and_destroy(self):
        imagebank = ImageBank.open(self.bank_path)

        self.assertTrue(len(imagebank.entries) == 2)

        for e in imagebank.entries:
            print e

        # Test removing the images
        imagebank.remove_image('kirk.jpg')
        imagebank.remove_image('kirk_duplicate.png')
        self.assertTrue(len(imagebank.entries) == 0)

        # Delete the bank
        # TODO maybe there should be delete in the ImageBank API
        os.remove(self.csv_path)