Skip to content

Instantly share code, notes, and snippets.

@UserUnknownFactor
UserUnknownFactor / animate_pngs.py
Last active August 22, 2024 15:37
Tool to find images named prefix_NN_postfix.png and convert them to APNGs
import os, re, glob
import numpy as np
from PIL import Image, ImageChops
from collections import defaultdict
# Finds sequences of images with common name part+_<frame#>_etc.png
# and merges them into a single animated PNG.
INITIAL_SPEED = 20
TYPE2 = True
@UserUnknownFactor
UserUnknownFactor / diff_pngs.py
Created August 22, 2024 12:00
Python script for automatic diffing of PNGs
# -*- coding: utf-8 -*-
# This script finds all PNGs of similar looks/size in the specified
# folder and produces a base image and a series of diffs with it.
import os
import sys
from PIL import Image
import numpy as np
from collections import defaultdict
DIFF_THRESHOLD = 0 # Adjust this based on diff sensitivity needed
@UserUnknownFactor
UserUnknownFactor / extract_exe.py
Last active June 7, 2025 08:13
Split a file into two by binary signature
import pefile
import sys
import os
import glob
def extract_exe_from_bundle(bundle_path, output_path=None, data_path=None):
if output_path is None:
output_path = os.path.splitext(bundle_path)[0] + "_real.exe"
if data_path is None:
data_path = os.path.splitext(bundle_path)[0] + "_data.bin"
@UserUnknownFactor
UserUnknownFactor / apply_texts.py
Last active June 30, 2024 10:21
Tools for mass image translation (text applying tested on PGMMV with images of the same type/size that only differ in text area)
import os, csv, glob, re
from PIL import Image, ImageDraw, ImageFont
"""
This tool can read translations from:
`original→translation→image_without_extension[;text_pos_x,text_pos_y;overlay_path;overlay_x,overlay_y;custom_font;font_size;font_color]`
formatted .csv file and apply it to all images in the specified folder, after replacing
background to a specified image at specified coordinates. Text supports colored borders
and style tags like <b>, <i> (not enabled now) or <color="#ff0000"> in the text.
All stuff is only configurable in the code.
"""
@UserUnknownFactor
UserUnknownFactor / pymd5.py
Last active May 24, 2024 08:18
Pure Python implementation of MD5 algorithm for experiments and custom mods
#!/usr/bin/python3
# RSA Data Security, Inc., MD5 message-digest algorithm
# Copyright (C) 1991-1992, RSA Data Security, Inc.
"""
## pymd5 module
### The MD5 hash implementation in pure Python
The module exposes same methods as hashlib.md5 and a couple of
low-level methods to help with crypto experiments.
@UserUnknownFactor
UserUnknownFactor / pgmmv_dec.py
Last active May 25, 2024 08:16
PGM MV file decryptor with a separate Twofish cryptography library
try:
from twofish import Twofish # use github.com/blazepaws/python-twofish
except:
from pytwofish import Twofish # since the included implementation is slow
import struct
from typing import List
from base64 import b64decode
import os
import json
@UserUnknownFactor
UserUnknownFactor / CultureInfoPatch.cs
Last active June 7, 2025 08:33
This is a C# patch for games locked to Japanese locale due to incorrectly using CultureInfo defaults
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("ja-JP", false);
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
@UserUnknownFactor
UserUnknownFactor / rpa_unpacker.py
Created March 8, 2024 12:47
Renpy raw .rpyc string extractor and repacker (useful if other tools fail to extract the strings)
#!/usr/bin/env python3
from __future__ import print_function
import sys
import os
import codecs
import errno
import random
try:
import pickle5 as pickle
@UserUnknownFactor
UserUnknownFactor / Photoshop_Duplicate-to-All-Text-Change.jsx
Last active March 2, 2025 11:09
Photoshop JS script to duplicate a group of layers to all files
// This script duplicates the current selected text and other layers to every open
// document and replaces text in the each of the text layers to the one specified in
// arrow separated CSV file in format: `{filename without extension}→Added text`
// it can automatically save modified files as PSDs and can additionally
// hide the only image layer in each document if present.
if (app.documents.length > 0) {
var csvFile = File.openDialog("Select CSV file", "Arrow Separated Values:*.csv", false);
if (csvFile) {
var csvData = readCSV(csvFile);
@UserUnknownFactor
UserUnknownFactor / dump_rbr_strings.py
Last active February 25, 2025 09:52
Bakin resource extractor
import os, re, argparse, glob
from unicodedata import category
from filetranslate.service_fn import write_csv_list, read_csv_list, read_csv_dict
from filetranslate.language_fn import tag_hash
# NOTE: This should work for both Bakin RPG Maker and Smile Game Builder files
def write_7bit_encoded_int(stream, value):
result = bytearray()
while True: