'Python 'Out of memory' when opening image

import pygame
from pygame.locals import * \

image = pygame.image.load('.\\w.jpg')

I'm trying to load an 59MB jpg file and it fails saying 'Out of memory' I'm using windows 64bit and python 3.10.4 64bit. My computer had more than 10GB of free ram left when the program ran.



Solution 1:[1]

As seen in the Wikipedia entry for JPEG, JPEG is a method of compression for digital images. So even if your jpg file is only 59MB the uncompressed image could take much more than that, depending on the amount of redundancy in the original image. The Wikipedia article asserts that JPEG typically achieves 10:1 compression and at first one might think, based on this assertion about typical compression rates, that even in uncompressed form that the image would not be too large. However, JPEG also uses Huffman coding and the amount of compression in Huffman coding can be extremely high if the uncompressed data is sufficiently redundant.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Tim Boddy