From ef5a0a9f9f621e0550dc05ebddbae3c3eac8f352 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 18 Jan 2020 19:47:54 +0530 Subject: Publish deploy 2020-01-18 19:47 --- .../index.html | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'posts/2020-01-14-Converting-between-PIL-NumPy') diff --git a/posts/2020-01-14-Converting-between-PIL-NumPy/index.html b/posts/2020-01-14-Converting-between-PIL-NumPy/index.html index 6c885f1..93b57d2 100644 --- a/posts/2020-01-14-Converting-between-PIL-NumPy/index.html +++ b/posts/2020-01-14-Converting-between-PIL-NumPy/index.html @@ -1,15 +1,19 @@ -Converting between image and NumPy array | Navan Chauhan
🕑 0 minute read.

Converting between image and NumPy array

import numpy
-import PIL
-
-# Convert PIL Image to NumPy array
-img = PIL.Image.open("foo.jpg")
-arr = numpy.array(img)
-
-# Convert array to Image
-img = PIL.Image.fromarray(arr)
-

Saving an Image

try:
-    img.save(destination, "JPEG", quality=80, optimize=True, progressive=True)
-except IOError:
-    PIL.ImageFile.MAXBLOCK = img.size[0] * img.size[1]
-    img.save(destination, "JPEG", quality=80, optimize=True, progressive=True)
+Converting between image and NumPy array | Navan Chauhan
🕑 0 minute read.

Converting between image and NumPy array

import numpy +import PIL + +# Convert PIL Image to NumPy array +img = PIL.Image.open("foo.jpg") +arr = numpy.array(img) + +# Convert array to Image +img = PIL.Image.fromarray(arr) +
+ +

Saving an Image

try: + img.save(destination, "JPEG", quality=80, optimize=True, progressive=True) +except IOError: + PIL.ImageFile.MAXBLOCK = img.size[0] * img.size[1] + img.save(destination, "JPEG", quality=80, optimize=True, progressive=True) +
+
Tagged with:
\ No newline at end of file -- cgit v1.2.3