Ren'Py import images tools for renpy

no im not

Newbie
Game Developer
Oct 5, 2018
31
64
Does anyone know which tools can help for importing images to code ?
like renpyhotspot tools, all we need to do is upload images and tools will send back code
If such tools does not exist, can someone create it ? it can save alot of time and very useful for Developers work
sorry for my bad english
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,547
2,161
I'm unfamiliar with renpyhotspot, so perhaps this isn't the answer you're looking for...

But for the most part, you don't need to import images into RenPy.
If you use scene this_is_my_background_image_001, it will load the first "this_is_my_background_image_001" image it finds in the images folder. That would usually be a .png, .webp or .jpg image.

show this_is_my_background_image_001 works equally well.

You don't need a corresponding image statement, RenPy will figure that out for you.

In fact, the only time you actually need image statements is if you're coding images how RenPy is intended to work, with the image identifier being more like image bg this is my background image 001 and you've decided NOT to name the images in the images folder the same way, including spaces.

Most common is something like:
image bg home livingroom daytime 001 = bg_home_livingroom_daytime_001
-or-
image eileen casual happy = eileen_casual_happy

If what you're trying to do is that... then RenPy can already do most of the heavy lifting for you. No specific import required, as long as you can follow your own file naming standard and do so consistently.

Have a look at

and here's how you might use it.
Python:
#gui.rpy

#Define all images
define config.automatic_images = [' ','_','-','/']
define config.automatic_images_strip = ['images']
There's a note to say it only searches for .png and .jpg. I haven't used it personally with .webp files, so I couldn't tell you if that note is still accurate or if it's out of date.
 
  • Like
Reactions: no im not

Epadder

Programmer
Game Developer
Oct 25, 2016
567
1,045
There's a note to say it only searches for .png and .jpg. I haven't used it personally with .webp files, so I couldn't tell you if that note is still accurate or if it's out of date.
Webp is not searched for by the automatic_images function, it's defunct code in PyTom's eyes.... As long as files are in the image folder and have unique names they will be found by Ren'py and can just be called by name (all lowercase).

There is an old thread , that has more info and a way to fix it by modifying Ren'py's files.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,547
2,161
Webp is not searched for by the automatic_images function, it's defunct code in PyTom's eyes.... As long as files are in the image folder and have unique names they will be found by Ren'py and can just be called by name (all lowercase).
Yeah.
It's odd. Because the thread I found the "older" code in that uses renpy.list_files() has a specific note that the code has been superseded with the addition of config.automatic_images. Even if the author has ultimately proved to be mistaken, it just feels like there was a solution that worked (list_files), then PyTom wrote something to replace it, then abandoned that something in favor of "the old way". Ah well. Such is life.

I've got example code that uses renpy.list_files(), but I'll wait to post it to see if this is actually what the OP is trying to do.

In the meanwhile, until PyTom actually deprecates automatic_images... it still works enough for most people's needs. Even if he personally would prefer it wasn't used.
 
  • Like
Reactions: no im not

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
9,946
14,547
There's a note to say it only searches for .png and .jpg. I haven't used it personally with .webp files, so I couldn't tell you if that note is still accurate or if it's out of date.
Like @Epadder said, it's still accurate. But it doesn't matter this much since Ren'py don't use the file extension to find the format of the image. So, just name your WEBP files ".jpg" and it will works fine.


This said :

The image statement is used to create what Ren'py call . Basically it just make the link between the file containing the image, and the data that Ren'py will use. So, as long as the displayables are simple image, you don't need to declare them, Ren'py make the link by itself when the game start.
Therefore, the image statement is only needed when you want more complex displayables. They can be , , and things like that.

As well as can be the tools used to generate the code, it will always be better to write it yourself. The only effective utility of renpyhotspot is that you don't have to note the coordinate somewhere to report them in Ren'py code. Once you want to go further, like conditioning one of the hotspot by example, you'll need to edit the code anyway. So it's better to write it from the start, you'll have a better understanding of it, and so a greater ability to correct it/tweak it.
 
  • Like
Reactions: no im not

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,547
2,161
i need to import images into a renpy game
Generally you don't need to.

Just put your images in the ./game/images/ folder and then use them within your RenPy code using scene:... like :

Python:
label start:

    scene black with fade

    "Start..."

    scene mypicture with dissolve   # Display a new scene (main background picture) with using a picture called "mypicture".
                                    # it could be mypicture.png, mypicture.jpg, mypicture.webp, etc.
                                    # as long as RenPy can find it somewhere in the /game/images/ folder... everything will work fine.

    "Hello player."

    # if your next picture was called "girlatbeach.jpg"... then you'd use:

    scene girlatbeach with dissolve

    "*** THE END ***"
    return

No "importing" required.

Just use the names of your pictures with scene: statements.