For details, see How to Use.
A Simple Tool for Making Specific Colors Transparent (Batch Processing Version)
This program is a lightweight VCSSL-based tool that opens all PNG image files in a folder, replaces a specific color with transparency, and saves the results to another folder.
If you're developing your own game or website, you've probably run into situations where you want to make the background of your graphics assets transparent.
Most graphics software supports this kind of task, but if you frequently perform simple conversions like "make green transparent," the process of launching the software, navigating menus, applying transparency, and saving can get a bit tedious.
So, this tool was designed to focus solely on that specific task.
Also, for processing just one image file, check out the standalone version introduced in this article: A Simple Tool for Making Specific Colors Transparent
Sponsored Link
How to Use
Download and Extract
At first, click the "Download" button at the above of the title of this page by your PC (not smartphone). A ZIP file will be downloaded.
Then, please extract the ZIP file. On general environment (Windows®, major Linux distributions, etc.), you can extract the ZIP file by selecting "Extract All" and so on from right-clicking menu.
» If the extraction of the downloaded ZIP file is stopped with security warning messages...
Execute this Program
Next, open the extracted folder and execute this VCSSL program.
For Windows
Double-click the following batch file to execute:
For Linux, etc.
Execute "VCSSL.jar" on the command-line terminal as follows:
java -jar VCSSL.jar
» If the error message about non-availability of "java" command is output...
If You Run Out of Memory While Running the Program...
Depending on how you use it, this program may consume a considerable amount of memory. As a result, the default memory allocation may not be sufficient in some cases. If you encounter such issues, please refer to the following:
» When You Run Out of Memory While Running the Program (for Microsoft® Windows® Users)
» When You Run Out of Memory While Running the Program (for Linux® and Other OS Users
Note: As a rough estimate, when processing a photo with a resolution of 4288 x 2848 pixels (about 12 megapixels), allocating around 3 GB (≈ 3000 MB) of memory should be sufficient.
Specify the Color to Make Transparent
When the program starts, you'll be prompted to input the color you want to make transparent. Rather than choosing a color by name, you'll enter the red, green, and blue values (RGB) separately, each as a number from 0 to 255.
If you're not familiar with RGB values, check out the link below. It includes both an explanation and a simple color tool:
For the included sample image, try making green transparent: Red = 0, Green = 255, Blue = 0.
Select the Input Folder
Next, the program will ask whether you want to specify the input folder (the folder containing the images to process). If you choose "Yes," you'll be prompted to select the folder.
If you select "No," the tool will automatically use the folder named "input" located inside the folder where the tool was extracted. This input folder includes a sample image named "sample.png". If this is your first time using the tool, try selecting gNoh and using the sample.

Note: This tool only makes colors that exactly match the specified color transparent. Make sure to use PNG files, and apply a solid, uniform color to the areas you want to make transparent. Files in other formats will not be recognized by this tool.
Select the Output Folder
You'll then be asked whether you want to specify the output folder (where the processed images will be saved). If you choose "Yes," youfll be prompted to select the folder.
If you choose "No," the tool will automatically use the folder named "output" located inside the extracted directory. If this is your first time using the tool, go ahead and select "No" here as well.
Execute the Transparency Process
After that, just sit back and let the tool do the work. All PNG image files in the input folder will be processed, with the specified color made transparent, and the results will be automatically saved in the output folder.
The saved files will have the same name as the original, with "_clear.png" added to the end. The output format is PNG.
If you skipped the input/output folder selections by choosing "No," you should find that the sample image from the input folder has been processed and saved into the output folder.
Here's what it looks like (this is the actual output from this tool): The green areas have been successfully made transparent, and the gray background shows through.

Code Overview
This program is written in VCSSL.
If you want to replace the specified color with another color instead of transparency, you can open the file ColorToClearMulti.vcssl in a text editor and modify it.
Since VCSSL is a scripting language, you don't need a separate compiler-just edit the code and run it directly. Its syntax is similar to C and easy to follow, especially if you have any experience with C or related languages.
This program is based on the code from the article:
The single-file processing code was reorganized into a function, and this function is now called repeatedly to process every file in a folder.
So if you're reading this for the first time, it might be easier to understand by starting with that earlier article.
Full Code
Let's start by looking at the full code:
coding UTF-8; // Specify character encoding (prevents garbled text)
import Graphics; // Import the graphics library for image processing
import File; // Import the file system library for file and folder operations
import Text; // Import the text processing library for string manipulation
// Default paths for input/output folders
const string DEFAULT_INPUT_DIRECTORY = "./input";
const string DEFAULT_OUTPUT_DIRECTORY = "./output";
// Get RGB values of the color to make transparent (input is requested before main() runs)
int fromRed = input("Red value of the color to make transparent (0-255)?", "0"); // Red component
int fromGreen = input("Green value of the color to make transparent (0-255)?", "255"); // Blue component
int fromBlue = input("Blue value of the color to make transparent (0-255)?", "0"); // Green component
int fromAlpha = 255; // Alpha of the original color (0 = transparent, 255 = opaque)
// Define the replacement color (change here if you want something other than transparency)
int toRed = 0; // Red component
int toGreen = 0; // Blue component
int toBlue = 0; // Green component
int toAlpha = 0; // Alpha (0 = transparent, 255 = opaque)
// ======================================================================
// Main process - This function is automatically called on startup
// ======================================================================
void main () {
// Prepare full paths for input and output folders
string inputDirectoryPath = getFilePath(DEFAULT_INPUT_DIRECTORY);
string outputDirectoryPath = getFilePath(DEFAULT_OUTPUT_DIRECTORY);
// Ask the user if they want to specify input/output folders; if yes, get the paths
if (confirm("Would you like to specify input/output folders? (Click 'No' to use defaults)")) {
inputDirectoryPath = choose("Select input folder", ".");
outputDirectoryPath = choose("Select output folder", ".");
}
// Process all files in the input folder and save them to the output folder
processAllFiles(inputDirectoryPath, outputDirectoryPath);
// Show completion message to the user
popup("Done! Please check the file list on screen and close the window.");
}
// ======================================================================
// Function that scans and processes all files in the folder
// ======================================================================
void processAllFiles(string inputDirectoryPath, string outputDirectoryPath) {
// Get list of file names and file count in the input folder
string fileNames[] = listDirectory(inputDirectoryPath);
int fileN = length(fileNames);
// Process each file in the input folder
for (int i=0; i<fileN; i++) {
// Combine file name with input folder path to get full file path
string inputFilePath = getFilePath(fileNames[i], inputDirectoryPath);
// If it's not a directory and the file ends with ".png", process it
if (!isDirectory(inputFilePath) && checkText(inputFilePath, ".png", Text.END)) {
// Create output file name by adding "_clear.png" to the input file name
string outputFileName = fileNames[i] + "_clear.png";
// Combine output file name with output folder path to get full path
string outputFilePath = getFilePath(outputFileName, outputDirectoryPath);
// Print input/output file paths to the console
println("INPUT: " + inputFilePath);
println(" > OUTPUT: " + outputFilePath);
// Run the transparency process
processFile(inputFilePath, outputFilePath);
}
}
}
// ======================================================================
// Function to process a single image file and save the result
// ======================================================================
void processFile(string inputFilePath, string outputFilePath) {
// Create a graphics resource from the input image file
int inputGraphics = newGraphics(inputFilePath);
// Create a new graphics resource with the specified color converted
int outputGraphics = newGraphics(
inputGraphics, // Original image graphics resource
fromRed, fromGreen, fromBlue, fromAlpha, // Color to convert (user-specified)
toRed, toGreen, toBlue, toAlpha // Replacement color (transparent)
);
// Save the output with a different file name
exportGraphics(outputGraphics, outputFilePath, "PNG"); // Save as PNG format
// Release resources
deleteGraphics(inputGraphics);
deleteGraphics(outputGraphics);
}
ColorToClearMulti.vcssl
That's it! The program is relatively short -- around 100 lines of code. It's written in a top-down structure, where each level adds more detail.
1While each part is explained in the inline comments, we'll go through the code step-by-step in the following section.
Header Section
Let's begin with the first two lines of the code:
coding UTF-8; // Specify character encoding (prevents garbled text)
import Graphics; // Import the graphics library for image processing
import File; // Import the file system library for file and folder operations
import Text; // Import the text processing library for string manipulation
code/import.txt
The first line declares the character encoding used in the file. While the program will usually work even without it, adding this line helps prevent garbled text.
The second line imports the Graphics library, which provides functions for working with graphics resources-in other words, image data. If you're wondering what exactly a "graphics resource" is, just think of it as the data structure VCSSL uses to store, display, and draw images. Everything needed to work with image files in VCSSL is handled through these graphics resources.
Next, we import the File library, which provides access to file system information and operations. In this program, it's used to get full folder paths, retrieve lists of file names within folders, and check whether a file path points to a folder.
Lastly, the Text library provides string manipulation functions. Here, it's used to check whether the file extensions at the end of the paths match ".png", the format supported by this tool.
Global Variables
Next up is the declaration of global variables:
// Default paths for input/output folders
const string DEFAULT_INPUT_DIRECTORY = "./input";
const string DEFAULT_OUTPUT_DIRECTORY = "./output";
// Get RGB values of the color to make transparent (input is requested before main() runs)
int fromRed = input("Red value of the color to make transparent (0-255)?", "0"); // Red component
int fromGreen = input("Green value of the color to make transparent (0-255)?", "255"); // Blue component
int fromBlue = input("Blue value of the color to make transparent (0-255)?", "0"); // Green component
int fromAlpha = 255; // Alpha of the original color (0 = transparent, 255 = opaque)
// Define the replacement color (change here if you want something other than transparency)
int toRed = 0; // Red component
int toGreen = 0; // Blue component
int toBlue = 0; // Green component
int toAlpha = 0; // Alpha (0 = transparent, 255 = opaque)
code/var.txt
At the top, we define default folder paths to use when the user skips folder selection by choosing "No." These are declared as constants using "const".
(The suffix DIRECTORY just means "folder," but it's a slightly more technical term.)
We also declare "toRed", "toGreen", "toBlue", and "toAlpha" to store the RGBA values of the replacement color.
User input for the RGBA values is done right in the declaration line using the input(...) function. Since these lines are written in the global scope, they run before the main() function is executed.
Technically, these variables don't need to be global. A more formal approach would be to declare them locally inside main() and pass them as arguments to the lower-level functions. However, since this is a small, simple utility program, writing everything globally like this makes it easier to tweak and reuse.
If you want to hard-code the original color or use a replacement color other than transparency, this is the section to modify.
The main Function - The Overall Flow
Next, let's look at the main() function.
If you're familiar with C or similar languages, this will look familiar -- main is automatically called when the program starts.
Here, we write the top-level control flow for the entire program.
// ======================================================================
// Main process - This function is automatically called on startup
// ======================================================================
void main () {
// Prepare full paths for input and output folders
string inputDirectoryPath = getFilePath(DEFAULT_INPUT_DIRECTORY);
string outputDirectoryPath = getFilePath(DEFAULT_OUTPUT_DIRECTORY);
// Ask the user if they want to specify input/output folders; if yes, get the paths
if (confirm("Would you like to specify input/output folders? (Click 'No' to use defaults)")) {
inputDirectoryPath = choose("Select input folder", ".");
outputDirectoryPath = choose("Select output folder", ".");
}
// Process all files in the input folder and save them to the output folder
processAllFiles(inputDirectoryPath, outputDirectoryPath);
// Show completion message to the user
popup("Done! Please check the file list on screen and close the window.");
}
code/main.txt
At the beginning, we declare variables to hold the full paths of the input/output folders. We then use the getFilePath(...) function to retrieve the full path for the default folders.
Next, the program asks the user whether they want to specify the folders. If the user selects "Yes," the paths are overwritten with folder paths selected via the choose(...) function.
After that, the processAllFiles(...) function is called with the input/output folder paths. This is a function defined within this code and will be explained next -- it goes through the folder contents and applies the transparency process to each file. That's the core operation of this tool.
Finally, the program displays a completion message using the popup(...) function. That's the end of the top-level logic.
You could call something like exit() to end the program here, but doing so would close the console window immediately. Instead, we leave the program running so the user can review the file list on screen. The program ends when the user manually closes the window.
The processAllFiles Function - Scanning and Processing All Files in a Folder
Let's move on to the processAllFiles(...) function, which is called from the main function. It takes two arguments: inputDirectoryPath and outputDirectoryPath. It processes all ".png" image files in the input folder, applying transparency and saving the results in the output folder.
// ======================================================================
// Function that scans and processes all files in the folder
// ======================================================================
void processAllFiles(string inputDirectoryPath, string outputDirectoryPath) {
// Get list of file names and file count in the input folder
string fileNames[] = listDirectory(inputDirectoryPath);
int fileN = length(fileNames);
// Process each file in the input folder
for (int i=0; i<fileN; i++) {
// Combine file name with input folder path to get full file path
string inputFilePath = getFilePath(fileNames[i], inputDirectoryPath);
// If it's not a directory and the file ends with ".png", process it
if (!isDirectory(inputFilePath) && checkText(inputFilePath, ".png", Text.END)) {
// Create output file name by adding "_clear.png" to the input file name
string outputFileName = fileNames[i] + "_clear.png";
// Combine output file name with output folder path to get full path
string outputFilePath = getFilePath(outputFileName, outputDirectoryPath);
// Print input/output file paths to the console
println("INPUT: " + inputFilePath);
println(" > OUTPUT: " + outputFilePath);
// Run the transparency process
processFile(inputFilePath, outputFilePath);
}
}
}
code/processAllFiles.txt
At the beginning of the function, we use listDirectory(...) to get a list of all files in the input folder. We then store the total number of files in fileN and loop over them with a for statement.
Inside the loop, we combine each file name with the input folder path using getFilePath(...) to get the full file path.
The if statement checks whether the file should be processed:
The first condition filters out any subfolders, which cannot be processed as image files. The second ensures that only ".png" files are included.
Inside the "{ ... }" block, we build the output file name and path, print both the input and output paths to the console for clarity, and finally call processFile(...), which performs the actual transparency operation.
That's the full logic for processAllFiles. In short, the program loops through all files in the input folder, checks whether each is a valid PNG image, and applies processFile(...) if so.
The processFile Function - Converting and Saving a Single Image
Finally, let's look at the heart of the tool: the processFile(...) function. This function takes inputFilePath and outputFilePath as arguments.
It opens the input image file, replaces a specified color with transparency, and saves the result to the output path as a PNG file.
// ======================================================================
// Function to process a single image file and save the result
// ======================================================================
void processFile(string inputFilePath, string outputFilePath) {
// Create a graphics resource from the input image file
int inputGraphics = newGraphics(inputFilePath);
// Create a new graphics resource with the specified color converted
int outputGraphics = newGraphics(
inputGraphics, // Original image graphics resource
fromRed, fromGreen, fromBlue, fromAlpha, // Color to convert (user-specified)
toRed, toGreen, toBlue, toAlpha // Replacement color (transparent)
);
// Save the output with a different file name
exportGraphics(outputGraphics, outputFilePath, "PNG"); // Save as PNG format
// Release resources
deleteGraphics(inputGraphics);
deleteGraphics(outputGraphics);
}
code/processFile.txt
As you can see, it's surprisingly simple! That's because the Graphics library already includes a built-in feature for this kind of operation:
VCSSL calls image data graphics resources, so we'll use that term here as well.
This function does three things:
- 1. Opens the image file specified by inputFilePath and loads it as a graphics resource.
- 2. Creates a new graphics resource by replacing the specified color.
- 3. Saves it to the location specified by outputFilePath as a PNG image.
That's it!
The last two lines free the used graphics resources. Although they would be released automatically when the program ends, graphics resources use a fair amount of memory, so it's good practice to free them manually, especially when processing many files.
This function is called repeatedly in the loop inside processAllFiles(...), once for each image file in the input folder. After all files have been processed, the loop ends, control returns to main, and the entire process is complete.
License
This VCSSL/Vnano code (files with the ".vcssl" or ".vnano" extensions) is released under the CC0 license, effectively placing it in the public domain. If any sample code in C, C++, or Java is included in this article, it is also released under the same terms. You are free to use, modify, or repurpose it as you wish.
* The distribution folder also includes the VCSSL runtime environment, so you can run the program immediately after downloading.
The license for the runtime is included in the gLicenseh folder.
(In short, it can be used freely for both commercial and non-commercial purposes, but the developers take no responsibility for any consequences arising from its use.)
For details on the files and licenses included in the distribution folder, please refer to "ReadMe.txt".
* The Vnano runtime environment is also available as open-source, so you can embed it in other software if needed. For more information, see here.
Simple Tool for Viewing and Converting Between RGB Values and Color Codes |
|
![]() |
Display and Convert RGB Values and Color Codes on a GUI Tool |
A Simple Tool for Making Specific Colors Transparent (Batch Processing Version) |
|
![]() |
Batch-Convert a Specific Color to Transparency in All PNG Files in a Folder |
A Simple Tool for Making Specific Colors Transparent |
|
![]() |
Convert a Specific Color to Transparency in PNG Image Files |
Simple Tool for Animating Sequential Images |
|
![]() |
A lightweight tool developed with VCSSL that allows you to play back sequential image files as an animation without converting them into a video file. |
Vertex Array-Based Model Deformation Animation |
|
![]() |
How to Deform 3D Surface Models Using a Grid-Based Vertex Array |
Creating a Model from a Vertex Array (Quadrangle Grid Mesh Format) |
|
![]() |
How to Create 3D Surface Models from a Grid-Based Vertex Array |