diff options
| author | yo mama <pepper@scannerjammer.com> | 2015-09-14 00:06:47 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2015-09-14 00:06:47 -0700 |
| commit | 23e19199befd69c06c1c11f1c11091d4445da91d (patch) | |
| tree | da3a068ac8f1d2c1c5802fa96e641b5aaf6ba44a /Pb/__init__.py | |
| parent | 5628ec9b1a2dc329c4d144c694f379ef5c055531 (diff) | |
ok...fixed grid up a bit more
Diffstat (limited to 'Pb/__init__.py')
| -rw-r--r-- | Pb/__init__.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Pb/__init__.py b/Pb/__init__.py index 586b363..ff0a764 100644 --- a/Pb/__init__.py +++ b/Pb/__init__.py @@ -55,18 +55,6 @@ class Pb(object): except Exception: raise Exception("Unable to call cmd {}".format(str(cmd))) - @staticmethod - def gif_frames(filepath): - try: - info = Popen([BIN_IDENTIFY,filepath], stdout=PIPE).communicate()[0] - frames = filter((lambda x: x), map( - (lambda x: x.split(" ")[0]), - (info).split('\n') - )) - return frames - except Exception as e: - self.err_warn("couldn't get gif frames") - raise e; @staticmethod def dimensions (filepath): @@ -100,6 +88,7 @@ class Pb(object): sys.stderr.write("ERROR:{} - {}\n".format(self.__class__.__name__, s)) def _cleanup(self): + if not self._files_created: return cmd = ["rm"]+self._files_created self._call_cmd(cmd) @@ -119,3 +108,20 @@ class Pb(object): sys.stderr.write("files created %s\n" % b._files_created) sys.stderr.write("commands %s" % " ".join(b.commands)) + @staticmethod + def gif_frames(filepath): + try: + info = Popen([BIN_IDENTIFY,filepath], stdout=PIPE).communicate()[0] + frames = filter((lambda x: x), map( + (lambda x: x.split(" ")[0]), + (info).split('\n') + )) + return frames + except Exception as e: + self.err_warn("couldn't get gif frames") + raise e; + + def _choose_gif_frame(self, filepath): + _gif_frames = Pb.gif_frames(filepath) + frame = random.choice(_gif_frames) + self._call_cmd([BIN_CONVERT, frame, filepath]) |
