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, 2019 in Python by Jinu
650 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, 2019 by Varsha

Related Questions In Python

+1 vote
6 answers
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, 2019 in Python by Omkar
• 69,040 points
6,762 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, 2019 in Python by JTM
728 views
0 votes
0 answers

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

I am getting the following error while ...READ MORE

Nov 28, 2019 in Python by Sumit
• 130 points
927 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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,057 views
0 votes
0 answers
+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, 2019 in Python by Mohammad
• 3,230 points
5,351 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, 2019 in Python by SDeb
• 13,250 points
365 views