### Navigation

- index
- modules |
- next |
- previous |
- PySDL2 0.9.0 documentation »
- API reference »
- sdl2.ext - Python extensions for SDL2 »

# Image loaders

`sdl2.ext.``get_image_formats`() -> (str, str, ...)

  Gets the formats supported by PySDL2 in the default installation.

`sdl2.ext.``load_image`(fname : str[, renderer=None[, assurface=False[, enforce=None]]]) → SDL_Surface, TextureSprite or SoftwareSprite

  Creates a `sdl2.SDL_Surface` from an image file.

  This function makes use of the Python Imaging Library, if it is available on the target execution environment. The function will try to load the file via `sdl2.sdlimage` first. If the file could not be loaded, it will try to load it via PIL.

  You can force the function to use only one of them, by passing the enforce as either `"PIL"` or `"SDL"`.

  Note

  This will call `sdl2.sdlimage.IMG_Init()` implicitly with the default arguments, if the module is available.

### Navigation

- index
- modules |
- next |
- previous |
- PySDL2 0.9.0 documentation »
- API reference »
- sdl2.ext - Python extensions for SDL2 »