summaryrefslogtreecommitdiff
path: root/lib/imgradient.py
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-03-03 21:09:57 -0800
committeryo mama <pepper@scannerjammer.com>2015-03-03 21:09:57 -0800
commitb083ace52f49b7f3cd858ea5f1eea2b417a47a8a (patch)
treeb524897f2b8d936a9f07ea17c74df86381ad513d /lib/imgradient.py
parent81dc62a3c958c3a0462a5d180f62395787d6ffe9 (diff)
added most of the api code
Diffstat (limited to 'lib/imgradient.py')
-rw-r--r--lib/imgradient.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/imgradient.py b/lib/imgradient.py
new file mode 100644
index 0000000..af743f1
--- /dev/null
+++ b/lib/imgradient.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python2.7
+import urllib
+import urllib2
+import simplejson as json
+import random
+import sys
+from lib.utils import post_request, Service
+
+IMGRADIENT_URL = "http://asdf.us/im/api/imgradient"
+
+
+
+class ImGradient(Service):
+ def __init__(self):
+ self.url = IMGRADIENT_URL
+ self._required_keys = [
+ "width", "height",
+ "color1", "color2",
+ "stripes",
+ "stripenumber", "stripeintensity",
+ "blurriness",
+ "contrast",
+ "brightness", "saturation", "hue",
+ "halftone",
+ "bevel", "percentbeveled",
+ "rotate", "flip", "flop", "tilt",
+ "filetype",
+ "gradienttype",
+ "username",
+ ]
+ def new(self, params):
+ for k in self._required_keys:
+ if not k in params:
+ params[k] = "";
+ self.params = params
+ return json.loads(post_request(IMGRADIENT_URL, self.params))
+