summaryrefslogtreecommitdiff
path: root/lib/pb/grid.py
diff options
context:
space:
mode:
authorPepper <pepper@scannerjammer.com>2015-09-26 22:00:15 -0400
committerPepper <pepper@scannerjammer.com>2015-09-26 22:00:15 -0400
commit0e9991e9bd5748a6d32c825e0a00a5ac15c29982 (patch)
tree7bf222228a84793f1980db61a37c060afa616541 /lib/pb/grid.py
parent4ebeb643da6419835e9ac3adb731e38a8ec9c7b4 (diff)
linting...
Diffstat (limited to 'lib/pb/grid.py')
-rwxr-xr-xlib/pb/grid.py70
1 files changed, 37 insertions, 33 deletions
diff --git a/lib/pb/grid.py b/lib/pb/grid.py
index 0fafd1c..d8b1aaa 100755
--- a/lib/pb/grid.py
+++ b/lib/pb/grid.py
@@ -1,36 +1,32 @@
-import sys
-import re
-import os
-import simplejson as json
-import random
from config import DEFAULT_FINALFORMAT, DEFAULT_HEIGHT,\
- DEFAULT_WIDTH, WORKING_DIR, OUTPUT_IMAGE_TYPES
+ DEFAULT_WIDTH, OUTPUT_IMAGE_TYPES
from config import THREEDROTATE, GRID, BIN_CONVERT, BIN_COMPOSITE
-import tempfile
from pb import Pb
-_default_line_color = "silver"
+_DEFAULT_LINE_COLOR = "silver"
class PbGrid(Pb):
+ """
+ Creates or overlays a grid on an image, and adds 3D perspective
+ """
example_params = {
- 'bgimage' : 'http://i.asdf.us/im/1a/imBreak_1424909483_xx_abridged___.gif',
- 'planebgimage' : 'http://i.imgur.com/FICZtph.png',
- 'tilt' : '30',
- 'spacing' : '30',
- 'hlines' : 'true',
- 'roll' : '30',
- 'shadow' : 'true',
- 'trim' : 'true'
+ 'bgimage': 'http://i.asdf.us/im/1a/imBreak_1424909483_xx_abridged___.gif',
+ 'planebgimage': 'http://i.imgur.com/FICZtph.png',
+ 'tilt': '30',
+ 'spacing': '30',
+ 'hlines': 'true',
+ 'roll': '30',
+ 'shadow': 'true',
+ 'trim': 'true'
}
- def __init__(self, **kwargs ):
- super(PbGrid,self).__init__(**kwargs)
+ def __init__(self, **kwargs):
+ super(PbGrid, self).__init__(**kwargs)
_definitions = {
'width': {'type':'int'},
'height': {'type':'int'},
'linethickness': {'type':'int', 'default': 1},
'opacity': {'type':'float', "default": 1.0},
'linecolor': {'type':'color', 'default': 'whitesmoke'},
- 'linethickness': {'type':'int'},
'spacing': {'type':'int', 'default': 10},
'vlines': {'type':'bool'},
'hlines': {'type':'bool'},
@@ -72,13 +68,15 @@ class PbGrid(Pb):
url=self.params.planebgimage['url'], extension=self.params.finalformat
)
else:
- self.filename, self.filepath = self._filename_filepath_create(
- extension=self.params.finalformat
- )
+ self.filename, self.filepath = self._filename_filepath_create(
+ extension=self.params.finalformat
+ )
self._db_url_param = str(
filter(
- lambda n: n, [self.params.imageinstead, self.params.planebgimage, self.params.bgimage, "NULL"]
+ lambda n: n, [
+ self.params.imageinstead, self.params.planebgimage, self.params.bgimage, "NULL"
+ ]
)[0]
)
@@ -106,25 +104,31 @@ class PbGrid(Pb):
cmd += ["-s", "{},{}".format(height, self.params.spacing)]
else:
cmd += ["-s", self.params.spacing]
- cmd += [ "-c", self.params.linecolor or _default_line_color]
- if self.params.linethickness: cmd += ['-t', self.params.linethickness]
- if self.params.opacity: cmd += ['-o', self.params.opacity]
- cmd += [ self.filepath, self.filepath ]
+ cmd += ["-c", self.params.linecolor or _DEFAULT_LINE_COLOR]
+ if self.params.linethickness:
+ cmd += ['-t', self.params.linethickness]
+ if self.params.opacity:
+ cmd += ['-o', self.params.opacity]
+ cmd += [self.filepath, self.filepath]
self._call_cmd(cmd)
def _shadow_cmd(self):
- #convert 1.png \( +clone -background black -shadow 110x1+9+9 \) +swap -background none -layers merge +repage 2.png
+ """
+ convert 1.png \
+ \( +clone -background black -shadow 110x1+9+9 \) \
+ +swap -background none -layers merge +repage 2.png
+ """
cmd = [
BIN_CONVERT,
self.filepath,
- "(","+clone","-background","black","-shadow","100x2+20+10",")",
- "+swap","-background","none","-layers","merge","+repage" ,
+ "(", "+clone", "-background", "black", "-shadow", "100x2+20+10", ")",
+ "+swap", "-background", "none", "-layers", "merge", "+repage",
self.filepath
]
self._call_cmd(cmd)
- def _threed_rotate_cmd (self):
+ def _threed_rotate_cmd(self):
#3rd step--run 3Drotate
cmd = [THREEDROTATE]
if self.params.swing: cmd += ["pan={}".format(self.params.swing)]
@@ -140,11 +144,11 @@ class PbGrid(Pb):
cmd += ["bgcolor=none"]
cmd += ["skycolor={}".format(self.params.skycolor or 'none')]
if self.params.transition: cmd += ["vp={}".format(self.params.transition)]
- cmd += [ self.filepath, self.filepath ]
+ cmd += [self.filepath, self.filepath]
self._call_cmd(cmd)
- def _trim_cmd (self):
+ def _trim_cmd(self):
cmd = [BIN_CONVERT, self.filepath, "-trim", "+repage", self.filepath]
self._call_cmd(cmd)