This topic is 883 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello. I am in the process of learning sdl2 with pysdl. I copied this simple code snippet to load a jpeg and it causes an error:

    window = sdl2.ext.Window("SDL2 Image Test", size=(800, 600))
window.show()

renderer = sdl2.ext.Renderer(window, -1, 0)
image = sdl2.ext.load_image("test_img.jpg", enforce="SDL") # <--- ERROR

running = True
while running:
events = sdl2.ext.get_events()
for event in events:
if event.type == sdl2.SDL_QUIT:
running = False
break
window.refresh()

Here is the error output, which I find very uninformative:

File "sdlimg", line 24, in <module>
main()
File "sdlimg", line 12, in main
File "/usr/lib64/python3.5/site-packages/sdl2/ext/image.py", line 71, in load_image
raise SDLError(sdlimage.IMG_GetError())
sdl2.ext.common.SDLError: b'JPEG loading error'

I tried searching the error and got literally no results. I also tried sdl2.sdlimage.IMG_Load() instead but then it simply gives a "wrong type" error. I tested with BMP files and they load fine.

So anyone have any ideas why it fails to load JPG images?

-

Or if there is another way to achieve hardware-accelerated image rendering in python that integrates well with PyGObject/GTK then I'd like to hear about it.

Thank you!

##### Share on other sites

Today I got a lot of this errors (not Py, not SDL), where the jpg was really a png or where a file was opened exclusively by another app. Sure about the path? JPEG2000? File extension jpeg jpg jiff ? You know this not programming errors.

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 39
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631718
• Total Posts
3001880
×