Ren'Py Backcompatibility after change .png to .webp

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
Hey guys and girls,

I want to reduce the Size of my Game, want go from .png to .webp all pics ingame are defined.

What lines do i need to set from old Savegames (.png) to reload the webp version?

Is there an possibility?

Greeting and thank
Blackthunder
 
Apr 24, 2020
192
257
I'm pretty sure that Renpy doesn't save images unless you are doing something special, so there should be no issues with compatibility.
The images would be the same, regardless of which save file that gets used, so Renpy should handle the new references automatically as part of the startup routine.
 
  • Like
Reactions: Blackthunder_vn

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
Option 1:

Leave all your images called stuff like /prolog/jonas_anruf.png - even though the actual files are in *.webp format.​
That really depends on your image conversion software. But if you use Cruncher, here on F95 - it does exactly that. Converts all the file to the new format, but leaves their filenames exactly the same. (Obviously backup everything beforehand - to avoid potential fuck ups).
Some software would shit itself at that... but not RenPy. It doesn't really care what the file is called, only what the file header says the contents of the file contain.​
Option 2:

Probably more like you were expecting... convert all the files to their new format (and new filenames) and then change your code for each file changed from .png to webp.​
From what I can see in your code, most of your direct references to .png files are part of image statements. image definitions are NOT part of your save file. They are purely a runtime construct. So if you change them between releases, the game won't mind.​
If you are using the Atom editor, all you need to do is open the "[Find] -> [Find in Project]" menu (or press the [CTRL+SHIFT+f] shortcut) and do a search and replace.​
  • Find in Project : .png
  • Replace in Project: .webp
  • File/directory pattern : *.rpy
  • Click [Find All] followed by [Replace All] after you've reviewed the changes.
There may be a few places where you manually need to go back and change the filename back to .png, depending on which folders you've converted. (I'm thinking the options.rpy and gui.rpy files - that use images RenPy created rather than yourself).​
Alternatively, don't use the "in project". Instead just use the standard search and replace within each file and pick which files you want to do mass changes for.​


As as side note... You have a LOT of unnecessary image statements.

You have lines like image patreon_link = "/patreon_link/patreon_link.png".

(Unless you've disabled it) RenPy automatically generates image statements for any file stored in the /images/ folder and its subfolders. It strips off the folder names and the file extension when it names things.

The end result is that an image called /images/test/my_image_one.png would automatically be accessible using
scene my_image_one with dissolve without manually coding an image statement.

The process is introduced here :

As long as the filename and the image identifier are identical, you don't need to manually add that image statement. Things get a little trickier if you have two (or more) files named exactly the same in different folders. But if you had that, you'd already have image statements where the image identifier was different from the filename.

If you're renaming all your images. One way to simplify things would be to remove all those extraneous image statements from your code and let RenPy generate the correct image definition for you. Again, image definitions are NOT stored in save files - so removing them from your code won't affect save compatibility.
 
Last edited:

Blackthunder_vn

Active Member
Game Developer
Jan 31, 2020
582
1,467
Ok, thanks so far I test it. Just wanted to dont have an game breaking bug afterwards.

Thanks Blackthunder