def test_pil(self): try: import Image except ImportError: from PIL import Image image = Image.open(os.path.join(self._folder, 'images', 'link.gif')) result = list(quirc.decode(image)) self.assertEqual(len(result), 1) code = result[0] self.assertEqual(code.data_type, 4) self.assertEqual(code.ecc_level, 0) self.assertEqual(code.size, 29) self.assertTupleEqual(code.corners, ((16, 16), (132, 16), (132, 132), (16, 132))) self.assertEqual(code.text, 'https://github.com/svartalf/python-quirc')
# -*- coding: utf-8 -*- """Decoding images using PIL for pre-processing""" import sys try: import Image except ImportError: from PIL import Image import quirc if __name__ == '__main__': try: for code in quirc.decode(Image.open(sys.argv[1])): print code.text except IndexError: print 'Usage: %s /path/to/qr/qr.image.jpg' % sys.argv[0]