"""
Experiment to use Pillow to create JPEGS
"""
import datetime
import os
import random

from imagecrosser import ImageCrosser
from patternedimage import PatternedImage
from shared import shared

if __name__ == '__main__':
    dims = (1080, 1080)
    dpis = [2880 // i for i in [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16]]
    print(dpis)
    # img = PatternedImage.new(PatternedImage.diamonds, dims=dims, colours=[(209, 123, 193), (123, 193, 209), (12, 19, 29)])
    # img = PatternedImage.new(PatternedImage.stripedMulti, dims=dims, colours=shared.randomRGBContrasting(5))
    # img = PatternedImage.new(PatternedImage.diamonds, dims=dims, colours=shared.randomRGBPair())

    currentGen = [PatternedImage.new(dims=dims) for i in range(10)]

    now = datetime.datetime.now()
    folder = now.strftime("generations\%Y%m%d_%H%M%S")
    os.mkdir(folder)

    for genID in range(12):
        print("\nWriting generation {}: ".format(genID), end='')
        count = 0
        for img in currentGen:
            print("{}, ".format(count), end='')

            # img.save("{}\gen{}_{}.jpg".format(folder, genID, count))
            img.save("{}\gen{}_{}.png".format(folder, genID, count))
            count += 1

        random.shuffle(currentGen)
        nextGen = []
        for i in range(len(currentGen) // 2):
            nextGen.extend(ImageCrosser.crossTesselated([currentGen[2 * i], currentGen[2 * i + 1]],
                                                        counts=(random.randint(2, 5), random.randint(2, 5))))
        currentGen = nextGen

    for d in dpis:
        for img in currentGen:
            img.save("{}\gen{}_{}_{}dpi.jpg".format(folder, genID, count, d), dpi=(d, d))

74eded17953516eb292a4d9d44bd71409eeadcd6
<mask token>

<mask token>
if __name__ == '__main__':
    dims = 1080, 1080
    dpis = [(2880 // i) for i in [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16]]
    print(dpis)
    currentGen = [PatternedImage.new(dims=dims) for i in range(10)]
    now = datetime.datetime.now()
    folder = now.strftime('generations\\%Y%m%d_%H%M%S')
    os.mkdir(folder)
    for genID in range(12):
        print('\nWriting generation {}: '.format(genID), end='')
        count = 0
        for img in currentGen:
            print('{}, '.format(count), end='')
            img.save('{}\\gen{}_{}.png'.format(folder, genID, count))
            count += 1
        random.shuffle(currentGen)
        nextGen = []
        for i in range(len(currentGen) // 2):
            nextGen.extend(ImageCrosser.crossTesselated([currentGen[2 * i],
                currentGen[2 * i + 1]], counts=(random.randint(2, 5),
                random.randint(2, 5))))
        currentGen = nextGen
    for d in dpis:
        for img in currentGen:
            img.save('{}\\gen{}_{}_{}dpi.jpg'.format(folder, genID, count,
                d), dpi=(d, d))

<mask token>
import datetime
import os
import random
from imagecrosser import ImageCrosser
from patternedimage import PatternedImage
from shared import shared
if __name__ == '__main__':
    dims = 1080, 1080
    dpis = [(2880 // i) for i in [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16]]
    print(dpis)
    currentGen = [PatternedImage.new(dims=dims) for i in range(10)]
    now = datetime.datetime.now()
    folder = now.strftime('generations\\%Y%m%d_%H%M%S')
    os.mkdir(folder)
    for genID in range(12):
        print('\nWriting generation {}: '.format(genID), end='')
        count = 0
        for img in currentGen:
            print('{}, '.format(count), end='')
            img.save('{}\\gen{}_{}.png'.format(folder, genID, count))
            count += 1
        random.shuffle(currentGen)
        nextGen = []
        for i in range(len(currentGen) // 2):
            nextGen.extend(ImageCrosser.crossTesselated([currentGen[2 * i],
                currentGen[2 * i + 1]], counts=(random.randint(2, 5),
                random.randint(2, 5))))
        currentGen = nextGen
    for d in dpis:
        for img in currentGen:
            img.save('{}\\gen{}_{}_{}dpi.jpg'.format(folder, genID, count,
                d), dpi=(d, d))

"""
Experiment to use Pillow to create JPEGS
"""
import datetime
import os
import random

from imagecrosser import ImageCrosser
from patternedimage import PatternedImage
from shared import shared

if __name__ == '__main__':
    dims = (1080, 1080)
    dpis = [2880 // i for i in [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16]]
    print(dpis)
    # img = PatternedImage.new(PatternedImage.diamonds, dims=dims, colours=[(209, 123, 193), (123, 193, 209), (12, 19, 29)])
    # img = PatternedImage.new(PatternedImage.stripedMulti, dims=dims, colours=shared.randomRGBContrasting(5))
    # img = PatternedImage.new(PatternedImage.diamonds, dims=dims, colours=shared.randomRGBPair())

    currentGen = [PatternedImage.new(dims=dims) for i in range(10)]

    now = datetime.datetime.now()
    folder = now.strftime("generations\%Y%m%d_%H%M%S")
    os.mkdir(folder)

    for genID in range(12):
        print("\nWriting generation {}: ".format(genID), end='')
        count = 0
        for img in currentGen:
            print("{}, ".format(count), end='')

            # img.save("{}\gen{}_{}.jpg".format(folder, genID, count))
            img.save("{}\gen{}_{}.png".format(folder, genID, count))
            count += 1

        random.shuffle(currentGen)
        nextGen = []
        for i in range(len(currentGen) // 2):
            nextGen.extend(ImageCrosser.crossTesselated([currentGen[2 * i], currentGen[2 * i + 1]],
                                                        counts=(random.randint(2, 5), random.randint(2, 5))))
        currentGen = nextGen

    for d in dpis:
        for img in currentGen:
            img.save("{}\gen{}_{}_{}dpi.jpg".format(folder, genID, count, d), dpi=(d, d))
