I’m releasing a command line tool I was using to analyze transparent overlays (32-bit png file) and calculate or guess the location of the transparent portion (a rectangle). Obviously, it only works if there’s only one transparent portion, which is the majority of the overlays out there.
It’s a python script, so you need to know how to use python.
uborder-tool v1.0.0
To know how to use the script, open a prompt and call the script with -h or -help to get some instructions. There’s only one required parameter: the image file (a 32-bit png). The rest is optional.
python.exe uborder-tool.py -h
usage: uborder-tool.exe [-h] [-o OUTPUT] [-s INT[1,100]] [-t INT[1,255]] [-p] image_file
Estimates coordinates from the inner rectangle based on alpha transparent image.
positional arguments:
image_file input file (32-bit png)
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
output file (file to output uborder params)
-s INT[1,100], --step INT[1,100]
search step size (bigger is faster, though less precise).
-t INT[1,255], --threshold INT[1,255]
threshold below which transparent pixel is detected.
-p, --preview print results and show an image with detected points in green.
If you use the option -o, it’ll print some results in a file with name and path defined by the user. The output file is optional and it’ll print scaling and aspect ratio params recommended to be used with uborder. So I usually save the output as a *.params or *.slangp file. If you know how to edit the script you can change what the script will write to the output.
Example of usage with image.png and output.params as output file:
python.exe uborder-tool.py "image.png" -o "output.params"
If you know how to process in batch, you can analyze hundreds of overlays in seconds or minutes and get all params you need.
OBS1: I may distribute a windows executable made by pyinstaller if python is a limitation and someone is interested.
OBS2: if you use the --preview option, it’ll open your default image app to load a temporary png identical to the input with the points detected in green.
Practical example: From Orionsangel-Original-Console pack, let’s analyze the atariplain.png overlay.
The overlay:
Using the script with default params and printing preview:
After running, it’ll show the input image with green point where the rectangle was detected:
It works with default params. If the showed points don’t make sense, you need to adjust params or see if the image has transparent watermarks in some hidden places. In this case you need to lower the threshold below the watermark alpha values or just delete the watermark just temporarily to get correct results.