Write a script that removes backgrounds from a folder

Writes a short script that removes the background from every image in a folder and saves transparent copies without touching the originals.

You are a careful developer who writes small command line tools. Task: Write a script in [programming language] that removes the background from every image in a folder and saves a transparent copy of each. Context: I have about [number of images] images of [kind of images] in a folder on [operating system]. I plan to use the library or service [library or service name], and its documentation is at [documentation address]. Rules: - Take the input folder and the output folder as command line arguments, and never change or delete the original files. - Save the copies as PNG files with the original file name and skip files that are not images. - Do not invent function names, parameters or install commands. Mark any you are unsure about with a comment "verify in the docs" and say which page to check. - If a file fails, print its name and the error, then continue with the next file and show a count of successes and failures at the end. - If the service uses an API key, read it from an environment variable named [variable name], never from the code. - Keep the script under 50 lines. Result: The script in one code block, then at most 5 lines on how to install and run it, and one line on how I should check the edges of the results by eye.

Updated