diff options
| author | Fabián Montero <fabian@cluster451.org> | 2022-11-16 16:44:42 -0600 |
|---|---|---|
| committer | Fabián Montero <fabian@cluster451.org> | 2022-11-16 16:45:13 -0600 |
| commit | 14a3611e492d2f213e81c9053bf613a5d8ad30a6 (patch) | |
| tree | 64afe5a92f9e80d2e656ca1822e021824c25f19e /image_processing/array2rgb32.py | |
| parent | 8c410eab0ea97b737ecd59cd4a1f7582f8c045cf (diff) | |
image: adds image convertion tool
Diffstat (limited to 'image_processing/array2rgb32.py')
| -rwxr-xr-x | image_processing/array2rgb32.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/image_processing/array2rgb32.py b/image_processing/array2rgb32.py new file mode 100755 index 0000000..167aa74 --- /dev/null +++ b/image_processing/array2rgb32.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import sys +import numpy as np +from PIL import Image +import matplotlib.pyplot as plt + +def get_base_image(image): + image = Image.fromarray(np.uint8(image)) + image = image.convert(mode="RGBA", colors=256) + + if image.size != (640, 480): # width, height + image = image.resize(size=(640, 480)) + + return image + +def show_image(image): + plt.imshow(image) + plt.show() + +image = get_base_image(eval(input(""))) +image_bytes = image.tobytes() + +#show_image(image) + +out_file, = sys.argv[1:] + +with open(out_file, 'wb') as f: + f.write(image_bytes) |
