[solved]How do i get the size of my image (in pixels)?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

[solved]How do i get the size of my image (in pixels)?

#1 Post by SONTSE » Thu Oct 02, 2014 3:36 pm

lets assume i have a declared image

image pic1 = "pic1.png"

how do i get its width and height in pixels?

I'm planning to use this to morph im.Scale() displayable so it will scale to the fixed width or height maintaining the aspect ratio. Maybe such displayable already exist and I fail to find it. If i do, please tell me. Many thanks
Last edited by SONTSE on Thu Oct 02, 2014 5:11 pm, edited 1 time in total.
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: How do i get the size of my image (in pixels)?

#2 Post by PyTom » Thu Oct 02, 2014 4:25 pm

If you really want to, you can use renpy.image_size.

It's a bad idea, since it requires loading the images at init time. It's far better to bite the bullet and code in image sizes.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Re: How do i get the size of my image (in pixels)?

#3 Post by SONTSE » Thu Oct 02, 2014 5:11 pm

Okay, I noted it, so, if performance or stability will cry this thing will be one suspected. I'll stick with it for now since "biting a bullet" method is also a quite an issue ^^
Well. Anyway - always thankful for you, PyTom! You do a great job =)
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

Post Reply

Who is online

Users browsing this forum: Google [Bot]