Python error "ValueError: size needs to be (int width, int height)" while using pygame.Surface

0 votes

I'm trying to build a game on python using pygame. I am stuck with this error:

self._image_surf = pygame.Surface("pygame.png").convert()
ValueError: size needs to be (int width, int height)

Can you help me out?

Lines causing error:

pygame.display.set_caption('Pygame pythonspot.com example')
self._running = True
self._image_surf = pygame.Surface("pygame.png").convert()
Jun 19 in Python by Jinu
18 views

1 answer to this question.

0 votes

pygame.Surface takes in integer values for building the image. You're giving an image as the parameter which is syntactically wrong.

Try:

pygame.Surface(100, 100)

This should work.

answered Jun 19 by Varsha

Related Questions In Python

0 votes
1 answer

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,500 points
7,618 views
0 votes
1 answer

Pyplot error "only size-1 arrays can be converted to Python scalars"

You can plot the chart by taking ...READ MORE

answered Jan 28 in Python by Omkar
• 67,120 points
975 views
0 votes
0 answers

Python error "only size-1 arrays can be converted to Python scalars"

I'm trying to plot the exponential and ...READ MORE

Jul 9 in Python by JTM
34 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 130 views
+4 votes
6 answers
0 votes
1 answer

How can I write a program to add two numbers using functions in python?

def add(a,b):      return a + b #when i call ...READ MORE

answered May 20 in Python by Mohammad
• 1,500 points
24 views
0 votes
1 answer

Python pygame error : Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found

Try installing libpng You can do it with ...READ MORE

answered May 31 in Python by SDeb
• 12,360 points
21 views