def generate(self, factor=1): thumb_name = self.get_storage_name(factor) tmpfile = MoveableNamedTemporaryFile(thumb_name) resizer = GmConvertCommand( infile=self.source, outfile=tmpfile.temporary_file_path(), options=self.get_gm_options(factor) ) assert resizer.execute() thumbnail_storage.save(thumb_name, tmpfile) return True
def test_get_command(self): options = SortedDict() options['trueflag'] = True options['+falseflag'] = True options['valueflag'] = 'somevalue' cmd = GmConvertCommand(infile='in.jpg', outfile='out.jpg', options=options) assert cmd.get_command() == [ 'gm', 'convert', 'in.jpg', '-trueflag', '+falseflag', '-valueflag', 'somevalue', 'out.jpg' ]
def generate(self, factor=1): thumb_name = self.get_storage_name(factor) tmpfile = MoveableNamedTemporaryFile(thumb_name) resizer = GmConvertCommand( infile=self.source, outfile=tmpfile.temporary_file_path(), options=self.get_gm_options(factor) ) assert resizer.execute(fail_silently=True) if self.options['pngquant'] and os.path.splitext(thumb_name)[1] == '.png': optimizer = PngquantCommand( pngfile=tmpfile.temporary_file_path(), quality=self.options['pngquant']) assert optimizer.execute() thumbnail_storage.save(thumb_name, tmpfile) return True