From 698c7a8bc602ead69fed2f0307d74c3528a38e0d Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Tue, 13 Aug 2013 17:42:42 -0700 Subject: [PATCH] added file argument to video resizer and added ascii resizer --- mediagoblin/media_types/ascii/processing.py | 46 +++++++++++++++++++++ mediagoblin/media_types/video/processing.py | 10 ++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/mediagoblin/media_types/ascii/processing.py b/mediagoblin/media_types/ascii/processing.py index 4cf8081a..82ee9cd7 100644 --- a/mediagoblin/media_types/ascii/processing.py +++ b/mediagoblin/media_types/ascii/processing.py @@ -189,6 +189,52 @@ class InitialProcessor(CommonAsciiProcessor): self.delete_queue_file() +class Resizer(CommonAsciiProcessor): + """ + Resizing process steps for processed media + """ + name = 'resize' + description = 'Resize thumbnail' + + @classmethod + def media_is_eligible(cls, entry=None, state=None): + """ + Determine if this media type is eligible for processing + """ + if not state: + state = entry.state + return state in 'processed' + + @classmethod + def generate_parser(cls): + parser = argparse.ArgumentParser( + description=cls.description, + prog=cls.name) + + parser.add_argument( + '--thumb_size', + nargs=2, + metavar=('max_width', 'max_height'), + type=int) + + # Needed for gmg reprocess thumbs to work + parser.add_argument( + 'file', + nargs='?', + default='thumb') + + return parser + + @classmethod + def args_to_request(cls, args): + return request_from_args( + args, ['size', 'file']) + + def process(self, thumb_size=None, file=None): + self.common_setup() + self.generate_thumb(thumb_size=thumb_size) + + class AsciiProcessingManager(ProcessingManager): def __init__(self): super(self.__class__, self).__init__() diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index 3f96dc66..ab78e8ed 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -309,14 +309,20 @@ class Resizer(CommonVideoProcessor): metavar=('max_width', 'max_height'), type=int) + # Needed for gmg reprocess thumbs to work + parser.add_argument( + 'file', + nargs='?', + default='thumb') + return parser @classmethod def args_to_request(cls, args): return request_from_args( - args, ['thumb_size']) + args, ['thumb_size', 'file']) - def process(self, thumb_size=None): + def process(self, thumb_size=None, file=None): self.common_setup() self.generate_thumb(thumb_size=thumb_size) -- 2.25.1