aboutsummaryrefslogtreecommitdiff
path: root/gantools/image_utils.py
diff options
context:
space:
mode:
authorVee9ahd1 <[email protected]>2019-05-20 20:11:37 -0400
committerVee9ahd1 <[email protected]>2019-05-20 20:11:37 -0400
commit3b1464dfb308af0a3eb6f23277a6988091fae6f9 (patch)
tree8df31fce53b450cab2e5c9933de590967f3638c2 /gantools/image_utils.py
parent2e27eb73344d691b657f72c8e794f81ce47036c6 (diff)
command line code and split image file save utilities into its own file
Diffstat (limited to 'gantools/image_utils.py')
-rw-r--r--gantools/image_utils.py10
1 files changed, 10 insertions, 0 deletions
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)