Home > front end >  Is there a way to increase the size of the background image in turtle?
Is there a way to increase the size of the background image in turtle?

Time:12-22

I am trying to make a game in python 3 which requires a background image. I already have the image. The problem here is my image looks small compared to the big screen. I don't want to change the size of the screen because then I would have to redo all the coordinates of the other objects on the screen. Is there any way I can increase the size of the background image?

Ps. I'm using Python 3 and on VS code.

Thanks in advance! This is the picture of what the small picture looks like.enter image description here

CodePudding user response:

In order to increase the size of the image, you would need too increase the resolution.

Assuming that you are using windows, open the png with Microsoft Photos, and click on the three horizontal dots at the top right.

A dropdown menu will open, press the third option from the top labeled "Resize"

After this, press on "Define custom dimensions" and you may manipulate the dimensions of the image as you like.

Then, simply save the resized image, and use it in your project.

Happy Coding!

CodePudding user response:

you can also do this using CV2 library

import cv2
image=cv2.imread("image.png")

scale_percent=1.5

width=int(image.shape[1]*scale_percent)

height=int(image.shape[0]*scale_percent)

dimension=(width,height)

resized = cv2.resize(image,dimension, interpolation = cv2.INTER_AREA)

print(resized.shape)

cv2.imwrite("output.png",resized)

OR you can use PIL library as well

from PIL import Image

image = Image.open("image.png")

image.save("output.png", dpi=(image.size[0]*1.5,image.size[1]*1.5))
  • Related