Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with latest Python 3.6 and AggDraw #5

Open
akblissweb opened this issue Apr 17, 2019 · 4 comments
Open

Issue with latest Python 3.6 and AggDraw #5

akblissweb opened this issue Apr 17, 2019 · 4 comments

Comments

@akblissweb
Copy link

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

@akblissweb
Copy link
Author

akblissweb commented Apr 17, 2019

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.

@akblissweb
Copy link
Author

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

@akblissweb
Copy link
Author

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. :-)

@Golova1111
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants