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

Cryptic error message if you draw in color on a grayscale image #5503

Closed
shirriff opened this issue May 18, 2021 · 1 comment · Fixed by #5504
Closed

Cryptic error message if you draw in color on a grayscale image #5503

shirriff opened this issue May 18, 2021 · 1 comment · Fixed by #5504

Comments

@shirriff
Copy link

shirriff commented May 18, 2021

What did you do?

Draw a color rectangle on a grayscale image.

What did you expect to happen?

Should draw a rectangle, or at least give an error explaining that you can't draw in color on a grayscale image

What actually happened?

The error message:

TypeError: function takes exactly 1 argument (3 given)

This error message is confusing since the rect function isn't being given 3 arguments; the arguments to rect match the documentation.

I ran into this problem and put an explanation on stackoverflow. This has received dozens of upvotes, so a lot of other people are hitting this problem. (This is why I think it's worth filing an issue on this.)

What are your OS, Python and Pillow versions?

  • OS: macOS Big Sur 11.2.3
  • Python: 3.9.4
  • Pillow: 8.2.0

Code to reproduce the problem:

from PIL import Image, ImageDraw
img = Image.new('L', (100, 100))
draw = ImageDraw.Draw(img)
draw.rectangle((0, 0, 10, 10), outline=(255, 0, 0))
@radarhere
Copy link
Member

I've created PR #5504 to change the error message to "color must be int or single-element tuple".

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

Successfully merging a pull request may close this issue.

2 participants