diff options
| -rw-r--r-- | photoblaster/modules/__init__.py | 4 | ||||
| -rwxr-xr-x | photoblaster/modules/pbgenerate/__init__.py | 24 | ||||
| -rwxr-xr-x | photoblaster/modules/pbgrid/__init__.py | 2 | ||||
| -rw-r--r-- | run_module_examples.py | 2 |
4 files changed, 26 insertions, 6 deletions
diff --git a/photoblaster/modules/__init__.py b/photoblaster/modules/__init__.py index edf4d3d..5d9d91a 100644 --- a/photoblaster/modules/__init__.py +++ b/photoblaster/modules/__init__.py @@ -56,7 +56,7 @@ class ModuleBase(object): #ModuleBase #and I made this private method that calls an imagemagick command #you see, right? yep - def _make_canvas(self, width, height, color, filepath): + def _make_canvas(self, width, height, color, fileobj): """ makes a canvas """ @@ -65,7 +65,7 @@ class ModuleBase(object): cmd = [ BIN_CONVERT, "-size", dimensions, bgcolor, - filepath + fileobj.get_filepath() ] self._call_cmd(cmd) diff --git a/photoblaster/modules/pbgenerate/__init__.py b/photoblaster/modules/pbgenerate/__init__.py index 419928b..f08dd85 100755 --- a/photoblaster/modules/pbgenerate/__init__.py +++ b/photoblaster/modules/pbgenerate/__init__.py @@ -149,6 +149,7 @@ class PbGenerate(ModuleBase): ] self._call_cmd(cmd) + def _convert(self): """Imagemagick convert command""" cmd = [BIN_CONVERT, self.params.url.get_file().get_filepath()] @@ -194,13 +195,32 @@ class PbGenerate(ModuleBase): cmd += [self.get_output_file().get_filepath()] self._call_cmd(cmd) + # if not self.params.format == "jpg": def add_white_bg(self): - if not self.params.format == "jpg": - return + width, height = self.get_output_file().get_dimensions() + tempfile = File( + is_temp=True, + extension=self.params.format, + ) + self._make_canvas( + width, + height, + "white", + tempfile + ) + cmd = [ + BIN_COMPOSITE, + self.get_output_file().get_filepath(), + tempfile.get_filepath(), + self.get_output_file().get_filepath(), + ] + self._call_cmd(cmd) def create(self): self._convert() + if self.params.format == "jpg": + self.add_white_bg() if self.params.background: self._composite() super(PbGenerate, self).create() diff --git a/photoblaster/modules/pbgrid/__init__.py b/photoblaster/modules/pbgrid/__init__.py index 06454fd..d2d7613 100755 --- a/photoblaster/modules/pbgrid/__init__.py +++ b/photoblaster/modules/pbgrid/__init__.py @@ -104,7 +104,7 @@ class PbGrid(ModuleBase): self.params.width or DEFAULT_WIDTH, self.params.height or DEFAULT_HEIGHT, self.params.bgcolor or 'transparent', - self.get_output_file().get_filepath() + self.get_output_file() ) #2nd step-- run grid diff --git a/run_module_examples.py b/run_module_examples.py index a682ab7..bda1411 100644 --- a/run_module_examples.py +++ b/run_module_examples.py @@ -4,7 +4,7 @@ from photoblaster.modules import Modules modules = Modules() for module_name in modules.list_modules(): - if module_name == "pbpattern": + if module_name == "pbgrid": print "\n\n\n" print "running example for %s" % module_name cls = modules.get_module(module_name) |
