You're fighting a losing battle. Once the files are on someone's machine, they can and will be able to gain access to them. You can't make it possible for the game to open them but not possible for anyone else.
Anyway, for protecting image files specifically, I guess I'd suggest this process (note that none of this code is available and I'm not writing it, but so you're aware of what's involved...):
- Create a
missing image handler to replace image access in your application. This is the way
JCC works
- Determine a way to construct a series of steps to obscure the image that can be reconstructed using
image manipulators. This will slow down image loading in your game
- I'd suggest the process for obscuring images would be to first seed a
random.Random instance using the image path as seed.
- Then you could try splitting images in a deterministic way that works in all cases, possibly decided by the random number generator. You might just decide to split all images above a certain size into a grid of images, with one randomly-selected image being unusually tall / short / wide / thin. Then shuffle the images, again using the random number generator, apply undoable image manipulator transforms like flip, matrix operations etc., creating randomly-generated filenames for these images and then dumping them in the directory.
- Note that you can't save images from Ren'Py, so I'd suggest writing a separate tool in
pillow to do the obfuscation and using the image manipulators in your Ren'Py game to reverse the task.
- Then you just need to do the same stuff, but in the opposite order in your game when loading images using the missing image handler.
- Once your game is filled with these garbage-named files that are scrambled, miscoloured and flipped chunks of images not really useful to anyone, you can exclude the original images from distribution
That will only make things very slightly harder for anyone to attack. Like I said, losing battle.