Tool JPG compressor tool (for HTML games and maybe others.)

Envyi

Newbie
Feb 12, 2019
60
20
Heyho everyone,

I made a small python script that searches a folder (default "OriginalGamesFiles") and copies all files in all subdirectories to a new folder ("CompressedGameFiles" by default) while converting all .png files to .jpg and replacing all occurences of ".png" in any .html file with ".jpg". All other files are just copied 1:1.
The foldernames can easily be changed in the script in line 5 and 6.

I mostly did this for Havensport, a game made with TWINE if i understood correctly. Could also work for Renpy games, since those just search for filenames without the suffix, right? Could add it, that .py files are also scanned and changed, if some Renpy dev could tell me if this is enough.

Required libs are just "os" and "PIL", not sure if those are pre-installed with Python, but can just be pip-installed easily.

Only issue ive noticed:
Some PNG files are encoded with RGBA (includes transparencies) which in my script are just converted to RGB and then saved as a JPEG, so if transparencies are needed this could cause issues. As i said, i did this for Havensport, and there everything looks the same, the whole game just went from 3GB to 300MB.


If anyone thinks the list of converted filetypes should be added, leave a comment "x to y" and i might add it.


PS: im new to python, so constructive criticism only, if any. No calling me names please, or i'll cry :p

Greetings and whatnot.
 

Nelix171

Active Member
Apr 10, 2020
639
404
just out of curiosity is there a reason why you gave the definition name as convertiamges and not convertimages?
 
  • Like
Reactions: Envyi

Envyi

Newbie
Feb 12, 2019
60
20
just out of curiosity is there a reason why you gave the definition name as convertiamges and not convertimages?
mostly lazyness of not wanting to fix it, so i used autocompletion to write the name again. i know... baaad. ^.^'
Only noticed it in the end, after i uploaded it, and then just "fuck it, its working."
 
  • Like
Reactions: Nelix171

Envyi

Newbie
Feb 12, 2019
60
20
This will convert to Webp. Haven't tested it yet
Ah Webp is a great idea. I dunno much about filetypes, but webp is pretty loss less too right?
I just saw a comment under the game asking for a conversion to jpeg and then crunched that together. But ye, webp seems better, plus its literally made for HTML i guess ^.^
 
  • Like
Reactions: lewdgamerxxx

lewdgamerxxx

Active Member
Compressor
Sep 6, 2018
725
2,125
Ah Webp is a great idea. I dunno much about filetypes, but webp is pretty loss less too right?
I just saw a comment under the game asking for a conversion to jpeg and then crunched that together. But ye, webp seems better, plus its literally made for HTML i guess ^.^
WEBP also supports transparency. WEBP is smallest format right now but soon it will be overtaken by (also supports transparency) in terms of lossless compression. It is in the final stages of standardization. Not sure when pillow will officially add support for it.
 
  • Like
Reactions: Envyi