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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emitet
    New Member
    • Feb 2018
    • 1

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

    Code:
    def make_square(im, min_size=0, fill_color=(206, 150, 106, 0)):
    	x, y = im.size
    	size = max(min_size, x, y)
    	new_im = Image.new('RGB', (size, size), fill_color)
    	new_im.paste(im, (float((size - x) / 2, (size - y) / 2)))
    	return new_im
    
    then i got error :
    TypeError                                 Traceback (most recent call last)
    <ipython-input-15-d7020999e20a> in <module>()
         11     size = (30, 30)
         12 
    ---> 13     img = make_square(img)
         14     img = img.resize(size, Image.ANTIALIAS)
         15     matrix = np.array(img)
    
    <ipython-input-14-8407033de8d8> in make_square(im, min_size, fill_color)
          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
    TypeError: float() takes at most 1 argument (2 given)

    help me please..
    Last edited by Frinavale; Mar 14 '18, 01:56 PM.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    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.

    Comment

    Working...