Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find the width of a image pygame

width = surface.get_size()[0]
height = surface.get_size()[1]
Comment

get height of image in pygame

import pygame as pg
pg.init()

rect = pg.Rect(x,y,width = 100, height = 50)
# method 1, returns a tuple of width and height
>>> print(rect.get_size())
(100,50)
# method 2, returns a specific value
>>> print(rect.get_width())
100
>>> print(rect.get_height())
50
Comment

pygame image get height

width = surface.get_width()
height = surface.get_height()

#Example
import pygame

imageInput = pygame.image.load("test.png")

#Loop through every pixel in the image, and print the colour at that position
for y in range(imageInput.get_height()):
    for x in range(imageInput.get_width()):
        print (imageInput.get_at((x, y)))
Comment

PREVIOUS NEXT
Code Example
Python :: python if boolean logic 
Python :: how to use ternary operater in python 
Python :: plt.tight_layout() cuts x axis 
Python :: check if a file exists in python 
Python :: to_frame pandas 
Python :: fill zeros left python 
Python :: decision tree python 
Python :: python random uuid 
Python :: django check if get parameter exists 
Python :: numpy make 2d array 1d 
Python :: tuple in python 
Python :: how to find python path 
Python :: how to make a list in python 
Python :: python zip files 
Python :: python opencv check image read 
Python :: how to make a grid in python 
Python :: how to add a new element to a list in python 
Python :: 2d array row and column 
Python :: NumPy flip Syntax 
Python :: tkinter python button 
Python :: Split the string using the separator 
Python :: list to text python 
Python :: add data to empty column pandas 
Python :: python choose function 
Python :: TfidfVectorizer use 
Python :: def calc_mean_mode(df, column_name) 
Python :: rename colonne pandas 
Python :: intersection of two lists using set method 
Python :: python scipy put more weight to a set value in curve_fit 
Python :: First Python Program: Hello World 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =