Font family:
Font size:

Border Adder

Known as CK2AutoBorder in previous incarnations

This program adds one-pixel-wide black borders to pixel-art maps, such as those exported from Crusader Kings II, Europa Universalis IV, and Victoria II. The borders are continuous—i. e., the pixels composing them never are merely diagonally adjacent to each other. (You can accomplish the same effect with GIMP's Roberts or Differential edge-detection filter, if you're willing to go through an extra step or two.)

The input image is not uploaded to a website and processed on a remote server; rather, it is processed locally in your browser with Javascript. You can read and edit the code with your browser's Inspect Element functionality, or by simply downloading this webpage and opening it in a text editor.

This program accepts both BMP and PNG files (in Chromium-based browsers; other browsers have not been tested). To download the output in PNG format, right-click on it and select the Save Image As option.

Due to a problem outside of my control (the lossy nature of converting to and from premultiplied alpha color values, according to the HTML standard), the output will have random pixels that are very slightly incorrect. (For example, a pixel that originally was (100, 100, 100) in the input may randomly become (100, 100, 99) in the output.) Rather than using the output image raw, it's advisable to manually copy the solid-black border from the output image to a version of the input image that has remained safe and lossless on your computer. (GIMP's select by color tool is recommended.) Blame the developers of HTML (or of your browser), not me, and feel free to implement this algorithm in a language other than Javascript. (The source code for a Golang implementation is available here; it doesn't have this problem, but you'll have to compile it yourself and use it through the command line.)

(The algorithm is extremely simple: For every pixel in the input image, if that pixel differs in color from its east, southeast, or south neighbor on the input image, then that pixel is colored black in the output image. Due to the problem described in the previous paragraph, however, this implementation merely prescribes that the sum of the differences in the red, green, and blue components between any two non-border pixels cannot exceed 3/(3 × 255) without the program's adding a border.)

Output image:

Input image:

Input image