coding UTF-8; // Specify character encoding (prevents garbled text) import Graphics; // Import graphics library for image processing // Ask the user to choose an image file and load it into a graphics resource string inputFilePath = choose("Please select the image file to convert.", "./"); int inputGraphics = newGraphics(inputFilePath); // Ask the user for the RGB values of the color to make transparent int fromRed = input("Red value of the color to make transparent (0-255)?", "0"); int fromGreen = input("Green value of the color to make transparent (0-255)?", "255"); int fromBlue = input("Blue value of the color to make transparent (0-255)?", "0"); int fromAlpha = 255; // Alpha of the original color (0 = fully transparent, 255 = fully opaque) // Define the replacement color (set this if you want to replace with a non-transparent color) int toRed = 0; // Red int toGreen = 0; // Green int toBlue = 0; // Blue int toAlpha = 0; // Alpha (0 = fully transparent, 255 = fully opaque) // Create a new graphics resource with the specified color converted int outputGraphics = newGraphics( inputGraphics, // Original image fromRed, fromGreen, fromBlue, fromAlpha, // Color to convert (input by user) toRed, toGreen, toBlue, toAlpha // Replacement color (transparent) ); // Save the result under a new file name string outputFilePath = inputFilePath + "_clear.png"; // Filename = original + "_clear.png" exportGraphics(outputGraphics, outputFilePath, "PNG"); // Save as PNG format popup("Conversion complete! Saved file: " + outputFilePath); // Show completion message // Clean up and exit deleteGraphics(inputGraphics); deleteGraphics(outputGraphics); exit();