From: Rodney Ewing Date: Wed, 14 Aug 2013 17:40:14 +0000 (-0700) Subject: added resizer for stl media X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a3cc93c6af284c7f3cd6712611bfc6fc0f040a4f;p=mediagoblin.git added resizer for stl media --- diff --git a/mediagoblin/media_types/stl/processing.py b/mediagoblin/media_types/stl/processing.py index 6adc68ae..2ec4241c 100644 --- a/mediagoblin/media_types/stl/processing.py +++ b/mediagoblin/media_types/stl/processing.py @@ -273,7 +273,58 @@ class InitialProcessor(CommonStlProcessor): self.delete_queue_file() +class Resizer(CommonStlProcessor): + """ + Resizing process steps for processed stls + """ + name = 'resize' + description = 'Resize thumbnail and mediums' + + @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( + '--size', + nargs=2, + metavar=('max_width', 'max_height'), + type=int) + + parser.add_argument( + 'file', + choices=['medium', 'thumb']) + + return parser + + @classmethod + def args_to_request(cls, args): + return request_from_args( + args, ['size', 'file']) + + def process(self, file, size=None): + self.common_setup() + if file == 'medium': + self.generate_perspective(size=size) + self.generate_topview(size=size) + self.generate_frontview(size=size) + self.generate_sideview(size=size) + elif file == 'thumb': + self.generate_thumb(size=size) + + class StlProcessingManager(ProcessingManager): def __init__(self): super(self.__class__, self).__init__() self.add_processor(InitialProcessor) + self.add_processor(Resizer)