def test_HDRGenerator(self): self.HDRgen = CompositeImage.HDRGenerator() hdr_conf = CompositeImage.HDRConfig('/tmp', prefix='HDRTest') m = mock.MagicMock() with mock.patch('CompositeImage.subprocess.call', m): self.HDRgen(self.CI, hdr_conf) # self.assertTrue(self.CI.getFilelist.called, 'HDRgen did not call CI getFilelist') tif_list = [ os.path.splitext(os.path.basename(img))[0] + '.TIF' for img in self.short_fl ] cmds = [] cmds.append(['align_image_stack', '-atmp', '-p/tmp/HDRTest.pto'] + ['/tmp/TIF/%s' % t for t in tif_list]) cmds.append(['enfuse', '-o/tmp/HDRTest.TIF'] + ['tmp%04d.tif' % i for i, t in enumerate(tif_list)]) for i, method_call in enumerate(m.method_calls): expected = mock.call.call(cmds[i]).call_list() l = len(expected) self.assertEqual(l, 1, "len(expected)=%d, should be 1" % l) self.assertEqual( method_call, expected[0], "call args list:\n%s\nexpected:\n%s" % (method_call, expected))
def GenerateHDRs(config, directory): symlink = CompositeImage.SymlinkGenerator() ProcessFolder(symlink, config, directory) image_ext = config.GetImageExt() if image_ext == '.tiff': generator = CompositeImage.RawToTifGenerator if image_ext == '.thumb.jpg': generator = CompositeImage.RawToThumbnailGenerator ProcessFolder(generator, config, directory) hdr_gen = CompositeImage.HDRGenerator() ProcessFolder(hdr_gen, config, directory)
import CompositeImage as CI import glob HDRworkdir = '/home/smb/HDR' HDRCollector = CI.CollectHDRStrategy() fl = glob.glob( '/home/smb/git/fotoworkflow/Python toolok/src/test_images/*.CR2') hdrs, sic = HDRCollector.parseFileList(fl) symlink_gen = CI.SymlinkGenerator() symlink_gen.setTargetDir(HDRworkdir) for hdr in hdrs: symlink_gen(hdr.getCompImage()) hdr_gen = CI.HDRGenerator() hdr_gen.setParams(HDRworkdir, '.tiff', 'test') #for i, hdr in enumerate(hdrs): # hdr_gen._prefix = 'test_%d' % i # hdr_gen(hdr.getCompImage()) hdr_gen(hdrs[0].getCompImage())
def executeGen(self, gen): if gen == None: gen = CompositeImage.HDRGenerator() task_id = self._ExecCmd(gen) return task_id