422,530 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,530 IT Pros & Developers. It's quick & easy.

float() takes at most 1 argument (2 given)

P: 1
Expand|Select|Wrap|Line Numbers
  1. def make_square(im, min_size=0, fill_color=(206, 150, 106, 0)):
  2.     x, y = im.size
  3.     size = max(min_size, x, y)
  4.     new_im = Image.new('RGB', (size, size), fill_color)
  5.     new_im.paste(im, (float((size - x) / 2, (size - y) / 2)))
  6.     return new_im
  7.  
  8. then i got error :
  9. TypeError                                 Traceback (most recent call last)
  10. <ipython-input-15-d7020999e20a> in <module>()
  11.      11     size = (30, 30)
  12.      12 
  13. ---> 13     img = make_square(img)
  14.      14     img = img.resize(size, Image.ANTIALIAS)
  15.      15     matrix = np.array(img)
  16.  
  17. <ipython-input-14-8407033de8d8> in make_square(im, min_size, fill_color)
  18.       3         size = max(min_size, x, y)
  19.       4         new_im = Image.new('RGB', (size, size), fill_color)
  20. ----> 5         new_im.paste(im, (float((size - x) / 2, (size - y) / 2)))
  21.       6         return new_im
  22.  
TypeError: float() takes at most 1 argument (2 given)

help me please..
Feb 13 '18 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 589
The error message is clear. float() converts one thing at a time. If you don't understand what is wrong, then do the arithmetic on the line(s) before calling float and send it one value.
Feb 13 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.