Tool Ren'Py WebPy.bat v0.1 - WebP based Image Compressor, RPA extractor included

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,723
18,881
webpy.png

WebPy.bat is a multithreaded WebP png/jpg image compressor, supporting both lossy and lossless compression, mainly aimed at compressing Ren'Py games although it can also be used for other engines, or just a basic directory of images. It uses for the image compression ( 'd to reduce size), to handle multithreading, and is also bundled.

No dependencies, no internet connection required. You can right click->edit to see the source. Works on Windows 7, 8 and 10. XP and Vista users might need this PowerShell update from Microsoft:

Instructions:
1. Copy WebPy.bat to the desired folder
- If you're compressing a Ren'Py game, this should be the /game/ folder
- If you're just compressing a directory of images, copy to the same directory as the images, it'll work recursively​
2. Double click on WebPy.bat to execute
3. Answer the prompts to begin

Images will be overwritten, make sure you have a backup of any files before continuing. Use at your own risk.

Converted files keep the same file extension as they had previously; ie, png images will keep the png file extension even though it's a WebP image. This is to make it easier to compress games, as no code changes/image definition updates are required.

Known Issues:
- Having non-ASCII characters in your folder path may cause issues

Let me know if you encounter any issues or bugs.

You don't have permission to view the spoiler content. Log in or register now.
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
Awesome!! :) Didn't even consider the option to keep the extension as png... I always did it in two versions, for android all images are defined as .webp while for everything else as .png X_x Would have saved me a lot of trouble :D
And since it's even doing that with .rpa files it will be much faster than what I did before (used a program that could only check one folder and create a new folder for the converted images... which kinda sucked because I always had to manually move all the files back to the right folders :D )
 

Glorious Cat

Active Member
Jul 25, 2017
749
2,388
Thank you :winkytongue:

Update : When using it, disable Avast CyberCapture or it'll be ugly :coldsweat:
 

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,723
18,881
Update : When using it, disable Avast CyberCapture or it'll be ugly :coldsweat:
It probably didn't like , an open source binary compression utility which I used for cwebp to reduce the file size. Some AVs may detect it, but it's completely safe.
 
  • Like
Reactions: Palanto

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
It's awesome, I tried it with our latest release now, it works like intended, no errors or problems encountered :) Thank you so much Sam, it's making life a lot easier on me now :D
 
  • Like
Reactions: Safetydummy and Sam

TCMS

Quote my posts if you want an answer
Donor
Former Staff
Aug 5, 2016
5,797
30,913
@Sam some of your code seems to cause a few problems
Code:
set "rpatool=%currentdir%_rpatool.py"
set "rpatoolps=%rpatool:[=`[%"
set "rpatoolps=%rpatoolps:]=`]%"
set "rpatoolps=%rpatoolps:^=^^%"
set "rpatoolps=%rpatoolps:&=^&%"
set "PYTHONPATH=%pythondir%Lib"
if /I "%unpack%" == "y" (
Folder name: New Folder (8)

Seems parentheses cause some sort of problem here. Since I'm not using it for ren'py and there doesn't seem to be any reason to actually set these unless the person accepts I went ahead and moved part of the code above like so:
Code:
if /I "%unpack%" == "y" (
set "rpatoolps=%rpatool:[=`[%"
set "rpatoolps=%rpatoolps:]=`]%"
set "rpatoolps=%rpatoolps:^=^^%"
set "rpatoolps=%rpatoolps:&=^&%"
set "PYTHONPATH=%pythondir%Lib"
And that fixed it. o.0
 
  • Like
Reactions: if95

Lorric17

Well-Known Member
May 25, 2017
1,153
1,254
This is pretty awesome. Ran it on Dreams of Desire twice. Original size = 4.3 GB. At lossless, the game actually got larger, up to 4.6 GB. At 90% setting, game got reduced to 0.9 GB, the game seems to work, is unpacked and the difference in image quality is not something I can see without having the images next to each other. DoD images are saved in .jpg format, so with a game using .png format, I imagine the gains to be even larger. Thanks, @Sam
 

Lorric17

Well-Known Member
May 25, 2017
1,153
1,254
@Jack73 Irfanview can open .webp files and save them in other formats. Gimp and paint.net doesn't seem to recognize .webp files. If you need to convert many files, you should look into ImageMagick.
 

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,723
18,881
Getting this error, any ideas? @Sam
I use UPX for compressing cwebp - . Unfortunately some AVs may detect UPX as some virus makers use it to disguise their exes. I'd suggest either adding an exception in your AV or using an alternative AV.
 

kiteares

Well-Known Member
Nov 15, 2017
1,028
1,238
@Jack73 Irfanview can open .webp files and save them in other formats. Gimp and paint.net doesn't seem to recognize .webp files. If you need to convert many files, you should look into ImageMagick.
and @Jack73
Just found GIMP has recently updated to 2.10.6, not sure if WebP is native to this build, but for previous ones there is a plugin.
There seems to have been a number of changes to the organisation recently that I've yet to explore, but I couldn't quickly locate the registry.
I've attached my 64bit D/L, please scan it at every stage in case something has got onto my machine since getting it, it should be fine, but I won't take responsibility.
 

s4msepi0l

Member
Jun 20, 2017
179
357
I use UPX for compressing cwebp - . Unfortunately some AVs may detect UPX as some virus makers use it to disguise their exes. I'd suggest either adding an exception in your AV or using an alternative AV.
Is there any way to change to uncompressed cwebp? I'd rather have the script be a few KB heavier than having to make exclusions on AC every time I use it :S
 
  • Like
Reactions: Palanto

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,723
18,881
Is there any way to change to uncompressed cwebp? I'd rather have the script be a few KB heavier than having to make exclusions on AC every time I use it :S
It'll be at least 4-5x the size, and significantly slower to launch.

What AV are you using? Most AVs nowadays no longer flag UPX.
 
  • Like
Reactions: Palanto

s4msepi0l

Member
Jun 20, 2017
179
357
It'll be at least 4-5x the size, and significantly slower to launch.

What AV are you using? Most AVs nowadays no longer flag UPX.
Just windows 10 default AV

EDIT: already fixed it by editing the script to use cwebp and ppx2 that I already had in my computer, seems to be working fine for now. Thanks.
 
  • Like
Reactions: Palanto

brynhildr

Compulsive Gambler
Jun 2, 2017
6,607
58,285
Unfortunately, for me doesn't work at all :/
I know that I've said something already on discord, but I'll post it even here so if a solution can be found at least others can see! Practically speaking, I copy the program on top of the folder or even inside it but while on top it says something but clearly doesn't do anything (and it's too damn fast too read it), inside the folder with the images gives me another message, and even though I can't read it fastly, it's certainly an error of some kind.

Since it's not a ren'py repack, of course I don't enable the thing of decompressing the .rpy files. After that I just press enter to leave the "lossless" quality and then I click again enter to leave the chosen threads based on the number of processors that I've (four) but... nothing at all :FeelsBadMan:
 

TCMS

Quote my posts if you want an answer
Donor
Former Staff
Aug 5, 2016
5,797
30,913
Unfortunately, for me doesn't work at all :/
I know that I've said something already on discord, but I'll post it even here so if a solution can be found at least others can see! Practically speaking, I copy the program on top of the folder or even inside it but while on top it says something but clearly doesn't do anything (and it's too damn fast too read it), inside the folder with the images gives me another message, and even though I can't read it fastly, it's certainly an error of some kind.

Since it's not a ren'py repack, of course I don't enable the thing of decompressing the .rpy files. After that I just press enter to leave the "lossless" quality and then I click again enter to leave the chosen threads based on the number of processors that I've (four) but... nothing at all :FeelsBadMan:
gyazo gif the error or use any other program to make a gif, and then just stop the gif and read the error ._.
 

brynhildr

Compulsive Gambler
Jun 2, 2017
6,607
58,285
gyazo gif the error or use any other program to make a gif, and then just stop the gif and read the error ._.
No need, I've solved the problem thanks to Sam and Boss on discord!

The solution was simple enough: if anybody needs to compress just a directory of images, make sure that you do so in a folder with no special characters ( such as "~" or "(" ) and no space whatsoever, otherwise the program might crash or give error!
 

TCMS

Quote my posts if you want an answer
Donor
Former Staff
Aug 5, 2016
5,797
30,913
No need, I've solved the problem thanks to Sam and Boss on discord!

The solution was simple enough: if anybody needs to compress just a directory of images, make sure that you do so in a folder with no special characters ( such as "~" or "(" ) and no space whatsoever, otherwise the program might crash or give error!
I provided a fix for that above ._.