diff options
| -rw-r--r-- | examples/db_interact.py | 47 | ||||
| -rw-r--r-- | get_data.py | 12 | ||||
| -rw-r--r-- | lib/param/color.py | 2 | ||||
| -rwxr-xr-x | lib/pb/gradient.py | 77 |
4 files changed, 53 insertions, 85 deletions
diff --git a/examples/db_interact.py b/examples/db_interact.py deleted file mode 100644 index d60037f..0000000 --- a/examples/db_interact.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python2.7 -import sys -sys.path.append('./lib') -from db import Db, ImCmd -import simplejson as json -db = Db() - - -def set_tag_generate(imcmd, tag="PbGenerate"): - dataobj = json.loads(imcmd.dataobj) - if dataobj.get("background"): - tag = "%s:%s" % ("PbGenerate", dataobj.get("compose")) - elif dataobj.get("transparent") != 'false': - tag = "PbGenerate:transparent" - imcmd.tag = tag - session.add(imcmd) - - -def set_tag_pattern(imcmd, tag="PbPattern"): - imcmd.tag = tag - session.add(imcmd) - -session = db.Session() - - -imcmd_list = session.query(ImCmd).filter_by(tag="PbGenerate").all() -for i in imcmd_list: - set_tag_generate(i) -session.commit() - -imcmd_list = session.query(ImCmd).filter_by(tag="dither").all() -for i in imcmd_list: - set_tag_pattern(i) -session.commit() - -imcmd_list = session.query(ImCmd).filter_by(tag="im").all() -for i in imcmd_list: - set_tag_generate(i) -session.commit() - -imcmd_list = session.query(ImCmd).filter_by(tag="True").all() -for i in imcmd_list: - set_tag_generate(i) -session.commit() - -# taglist = list(set(map(lambda n: n.tag, imcmd_list))) -# print taglist diff --git a/get_data.py b/get_data.py index 0e26b46..1f5f6e1 100644 --- a/get_data.py +++ b/get_data.py @@ -5,16 +5,10 @@ import simplejson as json URL_BASE = "http://asdf.us/im" IMAGES_I_LIKE = [ - "http://i.asdf.us/im/de/imgrid_1326006923_xx_abridged___.png", - "http://i.asdf.us/im/b7/imgrid_1328122947_xx_abridged___.png", - "http://i.asdf.us/im/13/imgrid_1327739154_imgrid_1327738736_xx_abridged___pepper_pepper.png", - "http://i.asdf.us/im/3a/imgrid_1328122609__1328122055_.gif", - "http://i.asdf.us/im/29/imgrid_1347748334_xx_abridged___pepper.png", - "http://i.asdf.us/im/af/imGrid_1435899447_dmgk.png", "http://i.asdf.us/im/da/imGrid_1435899431_dmgk.png", - "http://i.asdf.us/im/e1/Over_1435899330_dmgk.png", - "http://i.asdf.us/im/49/imGrid_1435898499_dmgk.png", - "http://i.asdf.us/im/dd/imGradientyellow-blue_1435898433_.png", +# "http://i.asdf.us/im/e1/Over_1435899330_dmgk.png", +# "http://i.asdf.us/im/49/imGrid_1435898499_dmgk.png", +# "http://i.asdf.us/im/dd/imGradientyellow-blue_1435898433_.png", ] diff --git a/lib/param/color.py b/lib/param/color.py index 02d694d..829a8f4 100644 --- a/lib/param/color.py +++ b/lib/param/color.py @@ -15,6 +15,8 @@ class Color(Param): except Exception as e: self.err_warn("Unable to sanitize the color: %s" % str(value)) self.err_warn(str(e)) + + def _color_sanitize(self, s): if s == "": return "transparent" diff --git a/lib/pb/gradient.py b/lib/pb/gradient.py index 9bca087..055f5b7 100755 --- a/lib/pb/gradient.py +++ b/lib/pb/gradient.py @@ -19,23 +19,24 @@ _halftone_values = { }
class PbGradient(Pb):
- example_params = {
- "width" : "200",
- "color1" : "#ffdead",
- "color2" : "blue",
- "stripes" : "true",
- "stripenumber" : "20",
- "gradienttype" : "radial",
- "stripeintensity" : "20",
- "halftone" : "checkeredfade",
- "percentbeveled" : "30",
- "flip" : "true",
- "bevel" : "flatinner",
- "rotate" : "20",
- "height" : "200",
- "filetype" : "jpg",
- "username" : "whatever"
- }
+ example_params = {'username': 'RICHARD_GIOVANNI', 'bevel': 'flatinner', 'saturation': '', 'rotate': 34, 'percentbeveled': 96, 'brightness': 79, 'stripenumber': 2, 'filetype': 'png', 'blurriness': 180, 'flip': '', 'height': 594, 'color1': 'rgb(191,125,24)', 'width': 536, 'color2': 'rgb(186,78,94)', 'gradienttype': 'mirrored', 'stripeintensity': 2515, 'tilt': 58, 'flop': '', 'halftone': 'etchedtransition', 'hue': 146}
+# example_params = {
+# "width" : "200",
+# "color1" : "#ffdead",
+# "color2" : "blue",
+# "stripes" : "true",
+# "stripenumber" : "20",
+# "gradienttype" : "radial",
+# "stripeintensity" : "20",
+# "halftone" : "checkeredfade",
+# "percentbeveled" : "30",
+# "flip" : "true",
+# "bevel" : "flatinner",
+# "rotate" : "20",
+# "height" : "200",
+# "filetype" : "jpg",
+# "username" : "whatever"
+# }
def __init__(self, **kwargs):
super(PbGradient, self).__init__(**kwargs)
_definitions = {
@@ -98,15 +99,15 @@ class PbGradient(Pb): ])
if self.params.rotate:
- cmd.extend(["-rotate", self.params.rotate])
+ cmd.extend(["-rotate", str(self.params.rotate)])
if self.params.tilt:
- cmd.extend(["-distort", "SRT", self.params.tilt])
+ cmd.extend(["-distort", "SRT", str(self.params.tilt)])
if self.params.flip == "true":
cmd.append("-flip")
if self.params.flop == "true":
cmd.append("-flop")
if self.params.contrast:
- cmd.extend(["-contrast-stretch", self.params.contrast])
+ cmd.extend(["-contrast-stretch", str(self.params.contrast)])
_gradients = {
"gradient" : ["gradient:{}-{}".format(self.params.color1, self.params.color2)],
"canvas" : ["canvas:{}".format(self.params.color1)],
@@ -119,19 +120,31 @@ class PbGradient(Pb): "colorspace" : [
"-colorspace",
"Gray",
- "plasma:{}-{}".format(self.params.color1, self.params.color2)
+ "plasma:{}-{}".format(
+ self.params.color1,
+ self.params.color2
+ )
],
"mirrored" : [
- "plasma:{}-{}".format(self.params.color1, self.params.color2),
- "\(", "+clone", "-flop", "\)",
- "append"
+ "plasma:{}-{}".format(
+ self.params.color1,
+ self.params.color2
+ ),
+ "(", "+clone", "-flop", ")",
+ "+append"
],
"plasmawash" : [
- "plasma:{}-{}".format(self.params.color1, self.params.color2),
+ "plasma:{}-{}".format(
+ self.params.color1,
+ self.params.color2
+ ),
"-set", "colorspace", "HSB"
],
"gradientwash" : [
- "gradient:{}-{}".format(self.params.color1, self.params.color2),
+ "gradient:{}-{}".format(
+ self.params.color1,
+ self.params.color2
+ ),
"-set", "colorspace", "HSB"
],
"noise" : ["xc:", "+noise", "Random", "-virtual-pixel", "tile"]
@@ -141,12 +154,16 @@ class PbGradient(Pb): if self.params.blurriness:
cmd.extend(["-blur", "0x{}".format(self.params.blurriness), "-auto-level"])
- if self.params.stripes == "true" and len(self.params.stripenumber):
+ if self.params.stripes and self.params.stripenumber:
cmd.extend(["-function", "Sinusoid"])
if self.params.stripeintensity:
- cmd.append("{},{}".format(self.params.stripenumber, self.params.stripeintensity))
+ cmd.append("{},{}".format(
+ self.params.stripenumber,
+ self.params.stripeintensity
+ )
+ )
else:
- cmd.append(self.params.stripenumber)
+ cmd.append(str(self.params.stripenumber))
if str(self.params.halftone) in _halftone_values:
cmd.extend([
"-ordered-dither",
@@ -161,6 +178,8 @@ class PbGradient(Pb): )
]
cmd.append(self.filepath)
+ import sys
+ sys.stderr.write("\n%s\n" % cmd)
self._call_cmd(cmd)
if self.params.bevel: self._make_bevel()
|
