Esempio n. 1
0
 def test_apply_image_filters(self):
     mock_filters()
     mock_new_request()
     req, res = vzzual.apply_image_filters('tests/test.jpg',
                                          ['facedetect','image_info'] )
     req.delete()
     self.assertEqual(req.state, 'done')
     self.assertIsNotNone(res)
Esempio n. 2
0
API_KEY_FILENAME = os.path.join(current_dir, 'vzzual.conf')

# Exit if the api doesn't exit
if not os.path.exists(API_KEY_FILENAME):
    print("Please put your vzzual api key into a file called %s" %
          API_KEY_FILENAME)
    sys.exit(1)

with open(API_KEY_FILENAME, 'r') as fp:
    token = fp.read().strip()

vzzual.init(token)
sample_image = os.path.join(current_dir, 'images/sample.jpg')

print("Creating Job .. ")
req, results = vzzual.apply_image_filters(
    sample_image, ["facedetect", "exif", "thumbnail"])
state = req.state

if state == 'error':
    print("Got errors:")
    pprint.pprint(req.get_errors())

elif state == 'done':
    print("Got results:")
    pprint.pprint(results)

    ## Get filter result for thumbnail
    thumb = next(r for r in results if r['filter'] == 'thumbnail')['result']

    vfile = vzzual.File.find(thumb['thumbnail'])
    thumbnail_path = os.path.join(current_dir, 'images', 'thumbnail.jpg')