genetic-lisa
genetic-lisa copied to clipboard
Issue with latest Python 3.6 and AggDraw
Hi,
Trying to get this to work in Python 3.6 and its complaining about
85
---> 86 return Image.fromstring('RGBA', IMAGE_SIZE, draw.tostring())
87
88
AttributeError: 'Draw' object has no attribute 'tostring'
Is there a specific version of AggDraw required? I will keep figuring it out but help would be appreciated.
Thanks
Ok, so the fromstring() and tostring() should now be frombytes() tobytes() the mut.next() should be next(mut)
I set the INITIAL_GENERATION to None so that it doesn't look for a non existent text file.
Now you can't save an RGBA to JPG in pillow and have to convert to RGB
imgToSave = crossover_strains[0].draw() # get image to save
imgToSave = imgToSave.convert("RGB") # convert to rgb
#crossover_strains[0].draw().save("%s.jpg" % (crossover_strains[0].name))
imgToSave.save("%s.jpg" % (crossover_strains[0].name)) # save image
Finally the rand range on the image will not work if you have an odd number of pixels so rounded it:
width = random.randint(0, round(IMAGE_SIZE[0]/2)) # added round
height = random.randint(0, round(IMAGE_SIZE[1]/2)) # added round
Seems working now, albeit slow ... feel free to update the code or make a Python3 version with your beautification of my hacks. :-)
Just a comment "for the future generations" If you would like to run the python script "as is" using python2 there are the requirements that you need:
pip install git+git://github.com/pytroll/aggdraw.git@ae274933793783251c205966f2793cb5a89c8407
for the aggdraw
pip install Pillow==2.9.0
for Pillow