From dfc509b95ff03d0c9027ee74d31d7b171f867bf1 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 26 May 2021 23:59:17 +0530 Subject: generated website --- .../2020-01-14-Converting-between-PIL-NumPy.html | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/posts/2020-01-14-Converting-between-PIL-NumPy.html (limited to 'docs/posts/2020-01-14-Converting-between-PIL-NumPy.html') diff --git a/docs/posts/2020-01-14-Converting-between-PIL-NumPy.html b/docs/posts/2020-01-14-Converting-between-PIL-NumPy.html new file mode 100644 index 0000000..7759e9a --- /dev/null +++ b/docs/posts/2020-01-14-Converting-between-PIL-NumPy.html @@ -0,0 +1,52 @@ + + + + + + + + + Hey - Post + + + + + +
+

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)
+
+ +
+ + + + + + \ No newline at end of file -- cgit v1.2.3