From 3b1464dfb308af0a3eb6f23277a6988091fae6f9 Mon Sep 17 00:00:00 2001 From: Vee9ahd1 Date: Mon, 20 May 2019 20:11:37 -0400 Subject: command line code and split image file save utilities into its own file --- gantools/image_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 gantools/image_utils.py (limited to 'gantools/image_utils.py') diff --git a/gantools/image_utils.py b/gantools/image_utils.py new file mode 100644 index 0000000..ca67134 --- /dev/null +++ b/gantools/image_utils.py @@ -0,0 +1,10 @@ +import PIL.image + +def save_image(arr, fp, format='JPEG'): + image = PIL.Image.fromarray(arr) + image.save(fp, format=format, quality=90) + +def save_images(ims, path_prefix='', format='JPEG'): + for i, im in enumerate(ims): + path = str(path_prefix)+str(i).zfill(4)+'.'+str(format).lower() + save_image(im, path) -- cgit v1.2.1