Resize pygame image

Asked 1 years ago, Updated 1 years ago, 76 views

What is the code for resizing images in pygame? I've been adjusting the size and saving the image until now, but it's very cumbersome, so I'm uploading it.

python pygame

2022-09-21 16:59

1 Answers

The transform module provides a function called scale.

https://www.pygame.org/docs/ref/transform.html#pygame.transform.scale

import pygame

img = pygame.image.load(file_name)
img_scale = pygame.transform.scale(img, (1280, 720)) # ScaleConversion

pygame.image.save(img_scale, new_file_name) #Save


2022-09-21 16:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.