summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpepperpepperpepper <pepper@scannerjammer.com>2016-03-06 18:35:19 -0800
committerpepperpepperpepper <pepper@scannerjammer.com>2016-03-06 18:35:19 -0800
commitc4df44415c48289a5bbeba8f68a3a0c1514a07ac (patch)
tree104180d3650eb215483b0847bbd8080600464950
parent0c737abada0764f2af3b0334485e0aaa415f4912 (diff)
final stretch
-rw-r--r--photoblaster/modules/pbconcat/__init__.py80
1 files changed, 51 insertions, 29 deletions
diff --git a/photoblaster/modules/pbconcat/__init__.py b/photoblaster/modules/pbconcat/__init__.py
index 21ef89b..707d04c 100644
--- a/photoblaster/modules/pbconcat/__init__.py
+++ b/photoblaster/modules/pbconcat/__init__.py
@@ -1,7 +1,7 @@
from photoblaster.modules import ModuleBase
from photoblaster.config import BIN_CONVERT, BIN_COMPOSITE, DEFAULT_FINALFORMAT
from photoblaster._file import File
-_DEFAULT_MODE = 'append'
+_DEFAULT_DIRECTION = 'right'
class PbConcat(ModuleBase):
@@ -11,8 +11,9 @@ class PbConcat(ModuleBase):
"http://dump.fm/images/20100924/"
"1285385385062-dumpfm-j1p2m3-animate.gif"),
'username': 'donkey',
- 'mode': 'append',
- 'frames_match': 'longest',
+ 'merge_direction': 'down',
+ 'frames_match': 'shorter',
+ 'dimensions_match': 'larger',
'finalformat': 'gif'
}
@@ -21,15 +22,20 @@ class PbConcat(ModuleBase):
_definitions = {
'img_url1': {'type': 'img_url'},
'img_url2': {'type': 'img_url'},
- 'mode': {
+ 'merge_direction': {
'type': 'enum',
- 'enum_values': ['append', 'stack'],
- 'default': _DEFAULT_MODE
+ 'enum_values': ['right', 'down'],
+ 'default': _DEFAULT_DIRECTION
+ },
+ 'dimensions_match': {
+ 'type': 'enum',
+ 'enum_values': ['smaller', 'larger'],
+ 'default': 'smaller'
},
'frames_match': {
'type': 'enum',
- 'enum_values': ['longest', 'shortest'],
- 'default': 'shortest'
+ 'enum_values': ['longer', 'shorter'],
+ 'default': 'shorter'
},
'finalformat': {
'type': 'enum',
@@ -75,26 +81,42 @@ class PbConcat(ModuleBase):
return frames
def _match_dimensions(self):
- """acts on image_url2 only"""
- dimensions1 = self.params.img_url1.get_file().get_dimensions()
- dimensions2 = self.params.img_url2.get_file().get_dimensions()
- if "jpg" in self.params.finalformat:
- self._add_canvas(
- self.params.img_url2.get_file(),
- canvas_color="white"
- )
- if self.params.mode == "append" and \
- dimensions1[1] != dimensions2[1]:
- self.params.img_url2.get_file().resize(
- height=dimensions1[1],
- module=self
- ) # make heights the same
- if self.params.mode == "stack" and \
- dimensions1[0] != dimensions2[0]:
- self.params.img_url2.get_file().resize(
- width=dimensions1[0],
- module=self
- ) # make widths the same
+ im1_width, im1_height = self.params.img_url1.get_file().get_dimensions()
+ im2_width, im2_height = self.params.img_url2.get_file().get_dimensions()
+ if self.params.merge_direction == "right" and \
+ im1_height != im2_height:
+ """match heights"""
+ if im1_height > im2_height:
+ if self.params.dimensions_match == "smallest":
+ self.params.img_url1.get_file().resize(
+ height=im2_height, module=self)
+ else:
+ self.params.img_url2.get_file().resize(
+ height=im1_height, module=self)
+ else:
+ if self.params.dimensions_match == "smallest":
+ self.params.img_url2.get_file().resize(
+ height=im1_height, module=self)
+ else:
+ self.params.img_url1.get_file().resize(
+ height=im2_height, module=self)
+ elif self.params.merge_direction == "down" and \
+ im1_width != im2_width:
+ """match widths"""
+ if im1_width > im2_width:
+ if self.params.dimensions_match == "smallest":
+ self.params.img_url1.get_file().resize(
+ width=im2_width, module=self)
+ else:
+ self.params.img_url2.get_file().resize(
+ width=im1_width, module=self)
+ else:
+ if self.params.dimensions_match == "smallest":
+ self.params.img_url2.get_file().resize(
+ width=im1_width, module=self)
+ else:
+ self.params.img_url1.get_file().resize(
+ width=im2_width, module=self)
def _concat_static(self, image1, image2):
tempfile = File(
@@ -102,7 +124,7 @@ class PbConcat(ModuleBase):
extension=self.params.finalformat,
)
cmd = []
- if self.params.mode == "stack":
+ if self.params.merge_direction == "down":
cmd = [
BIN_CONVERT,
image1.get_filepath(),