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

AttributeError: 'Draw' object has no attribute 'tostring' #99

Closed
dipeshSam opened this issue Sep 6, 2024 · 3 comments
Closed

AttributeError: 'Draw' object has no attribute 'tostring' #99

dipeshSam opened this issue Sep 6, 2024 · 3 comments

Comments

@dipeshSam
Copy link

I want to draw on internal image memory, tried the given code in the documentation, but following error has occurred. Also, I need this function very much.

Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import aggdraw
>>> d = aggdraw.Draw("RGB", (320, 200), "white")
>>> p = aggdraw.Pen("black", 0.5)
>>> d.line((0, 0, 500, 500), p)
>>> d.line((0, 500, 500, 0), p)
>>> s = d.tostring()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Draw' object has no attribute 'tostring'
>>>

Screenshot (197)
Any kind of help will be appreciated.
Thank you.

@djhoese
Copy link
Member

djhoese commented Sep 9, 2024

Ah that was changed a long time ago when multiple aggdraw repositories were merged. You can see the pull request here:

#12

The main thing was to match changes in Pillow (PIL) and Python itself where tostring was replaced by tobytes in Python 3 (if I'm remembering this correctly). It looks like all the actual code got updated, but not the example code.

So using tobytes should work. Let me know if it doesn't.

@dipeshSam
Copy link
Author

Dear @djhoese,

I sincerely appreciate your kind reply and great support. While I was aware that the documentation might be old, I wasn’t aware of the crucial detail that tostring had been replaced by tobytes. After investigating the tobytes method, I can confirm that it functions correctly and perfectly fine.

Screenshot attachment (solved):
successful_aggdraw_method
Thank you immensely! 😊
Regards

@djhoese
Copy link
Member

djhoese commented Sep 11, 2024

Fixed in #100. Released as 1.3.19. Thanks for the bug report!

@djhoese djhoese closed this as completed Sep 11, 2024
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