Mein Script funktioniert zwar,
trotzdem möchte ich wissen, wie man mit Literals in Python kodiert.
Bei meiner Image-Bearbeitung mit dem Modul Pillow öffne ich ein Image mit
Code: Alles auswählen
from PIL import Image
origPil = Image.open( filename )
origPil_mode = origPil.mode # ist 'I;16' für ein Image mit 16-bit Auflösung
img_array = np.asarray(origPil)
Code: Alles auswählen
img_to_show = Image.fromarray( img_array , mode = origPil_mode ) # mode is defined as lieral ?
from PIL import ImageShow
ImageShow.show(img_to_show)
img_to_show = Image.fromarray( img_array , mode = origPil_mode )
meckert mein VS Code Python:
Code: Alles auswählen
Argument of type "str" cannot be assigned to parameter
"mode" of type
"Literal['1', 'CMYK', 'F', 'HSV', 'I', 'l', "LAB', 'P', 'RGB', 'RGBA', 'RGBX', 'YCbCr'] | None"
in function "fromarray"
Type "str" cannot be assigned to type
"Literal['1', "CMYK', 'F', 'HSV', 'I', 'L', 'LAB', 'P', 'RGB', 'RGBA', ''RGBX', 'YCbCr'] | None"
wüsste ich auch nicht, wie die Zuweisung zu kodieren wäre.
Danke für die Diskussion
Erhy