Created
September 2, 2023 21:15
-
-
Save skarfie123/9cc5f7e142b66dd954c21a7f2e8b34d3 to your computer and use it in GitHub Desktop.
convert BMP images to PNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from PIL import Image | |
def main(): | |
input_folder = "output" | |
# List all files in the input folder | |
bmp_files = [f for f in os.listdir(input_folder) if f.lower().endswith(".bmp")] | |
for bmp_file in bmp_files: | |
# Open the BMP image | |
bmp_image = Image.open(os.path.join(input_folder, bmp_file)) | |
# Create the corresponding PNG filename | |
png_file = os.path.splitext(bmp_file)[0] + ".png" | |
png_path = os.path.join(input_folder, png_file) | |
# Save the BMP image as PNG | |
bmp_image.save(png_path, "PNG") | |
print("All BMP images converted to PNG successfully.") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment