'Why do I get a error after changing the file?

I am following a tutorial for a platformer game with pygame, but when i wan't to change the image file of the main character, I get this error:

image_surf = pygame.image.load(full_path).convert_alpha()

pygame.error: Unsupported image format

This error also accures I just move the file to an other folder and move it back right after. The only way it doasn't happen, is when i download the files and copy paste it into the right folder. I wanna change the png of the main character.

These are the files of the tutorial: https://github.com/clear-code-projects/2D-Mario-style-platformer/blob/main/5%20-%20fixes.zip The png file I'm talking about is in graphics - character - idle - 1.png
I do wan't to change all the png file, but I started with this one.

This is the function in whitch the error happens.

def import_folder(path):
    surface_list = []

    for _,__,image_files in walk(path):
        for image in image_files:
            full_path = path + '/' + image
            image_surf = pygame.image.load(full_path).convert_alpha()
            surface_list.append(image_surf)

    return surface_list

I tried to copy and move the same or a simular file with the same name in the same folder. It only worked if I copied the file from the original downloaded file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source