From 65967c3ea19e9c8a559903801e9d6f23f02419f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=A0=95=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Mon, 26 Mar 2018 16:25:31 +0900 Subject: [PATCH] Introduce image importer (#205) This commit introduces image importer to convert jpeg or png images to bin. The binary file only has the pixel values. It does not have size. The output will be used for `tflite_run`. Signed-off-by: Junghyun Kim --- tools/image_importer/image_importer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/image_importer/image_importer.py diff --git a/tools/image_importer/image_importer.py b/tools/image_importer/image_importer.py new file mode 100755 index 0000000..26aa2e4 --- /dev/null +++ b/tools/image_importer/image_importer.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +from PIL import Image +import sys +import struct + +if( len(sys.argv) < 3 ): + print("Usage: %s "%(sys.argv[0])); + exit(0) + +img = Image.open(sys.argv[1]) +outfile = sys.argv[2] + +print "Image format = ", img.bits, img.size, img.format + +with open(outfile, 'wb') as f: + f.write(img.tobytes()) + +print "Done." -- 2.7.4