'porting PIL python 2.x to pillow python3.10

I am trying to port an old library from python 2.x which uses PIL to Python 3.10 with PILLOW. right now I am stuck the old library uses the fromstring command:

im = Image.fromstring( 'F', (im_width, im_height), rawdata,
                               'raw', decoder )

which gives me the following error:

File "C:\...\DM3lib.py", line 688, in image
    im = Image.fromstring( 'F', (im_width, im_height), rawdata,
  File "C:\...\AppData\Roaming\Python\Python310\site-packages\PIL\Image.py", line 108, in __getattr__
    raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
AttributeError: module 'PIL.Image' has no attribute 'fromstring'

Can anyone give me a hint how to get the same functionality as the fromstring method?



Sources

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

Source: Stack Overflow

Solution Source