def filename(self): if self.filename is not None: return self.filename if self.title: return safe_filename(self.title) + self._suffix return hashlib.md5(self.content).hexdigest() + self._suffix
def process(infile, group_name, day, timeid, copies=1): mask = Mask((A4_WIDTH, A4_HEIGHT)) page = mask.apply_mask(infile) create_title(page, group_name, day, timeid) if not os.path.exists(os.path.join('png', day)): os.mkdir(os.path.join('png', day)) png_file = os.path.join('png', day, '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) page.save(png_file, quality=75) tools.print_image(png_file, copies)
def run(): names = os.listdir("infiles/") names.sort() for infile in names: day = tools.get_day() timeid = day + "/" + raw_input("Time id: ") group_name = raw_input("Group name: ") process(infile, group_name, timeid) os.rename("infiles/" + infile, "outfiles/{}_{}.jpg".format(timeid, tools.safe_filename(group_name)))
def process(infile, group_name, day, timeid, copies=1): mask = Mask((A4_WIDTH, A4_HEIGHT)) page = mask.apply_mask(infile) create_title(page, group_name, day, timeid) tools.mkdir_p(os.path.join('png', day)) png_file = os.path.join( 'png', day, '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) page.save(png_file, quality=75) tools.print_image(png_file, copies)
def run(): names = os.listdir('infiles') names.sort() for infile in names: day = tools.get_day() timeid = raw_input('Time id: ') group_name = raw_input('Group name: ') process(infile, group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name))
def on_process(self, event_): if self.validate(): timeid = time.strftime('%a/%H%M%S', time.localtime()) infile = self.filename group_name = self.group_name.GetValue() num_copies = self.num_copies.GetValue() if num_copies != '': process.process(infile, group_name, timeid, int(num_copies)) else: process.process(infile, group_name, timeid) shutil.copyfile(self.filename, 'outfiles/{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)))
def run(): names = os.listdir('infiles/') names.sort() for infile in names: day = tools.get_day() timeid = day + '/' + raw_input('Time id: ') group_name = raw_input('Group name: ') #timeid = time.strftime('%a/%H%M%S', time.localtime()) Process.process(infile, group_name, timeid) os.rename('infiles/' + infile, 'outfiles/{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) print 'Finished.'
def process(infile, group_name, day, timeid): page = Image.open(os.path.join('infiles', infile)) photo_size = (A4_WIDTH * 3 / 4, A4_HEIGHT * 3 / 4) photo_left = (A4_WIDTH - photo_size[0]) / 2 photo_top = (A4_HEIGHT - photo_size[1]) / 2 - A4_HEIGHT / 64 photo_right = photo_left + photo_size[0] photo_bottom = photo_top + photo_size[1] photo_rect = (photo_left, photo_top, photo_right, photo_bottom) create_title(page, (A4_WIDTH, A4_HEIGHT), photo_rect, group_name) tools.mkdir_p(os.path.join('png', day)) png_file = os.path.join('png', day, '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) page.save(png_file, quality=75) tools.print_image(png_file)
def on_process(self, event_): if self.validate(): timeid = time.strftime('%a/%H%M%S', time.localtime()) infile = self.names[self.index] group_name = self.group_name.GetValue() num_copies = self.num_copies.GetValue() if num_copies != '': process.process('infiles/' + infile, group_name, timeid, int(num_copies)) else: process.process('infiles/' + infile, group_name, timeid) os.rename('infiles/' + infile, 'outfiles/{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) self.load_next_image()
def process(infile, group_name, day, timeid): page = Image.open(os.path.join('infiles', infile)) photo_size = (A4_WIDTH * 3 / 4, A4_HEIGHT * 3 / 4) photo_left = (A4_WIDTH - photo_size[0]) / 2 photo_top = (A4_HEIGHT - photo_size[1]) / 2 - A4_HEIGHT / 64 photo_right = photo_left + photo_size[0] photo_bottom = photo_top + photo_size[1] photo_rect = (photo_left, photo_top, photo_right, photo_bottom) create_title(page, (A4_WIDTH, A4_HEIGHT), photo_rect, group_name) if not os.path.exists(os.path.join('png', day)): os.mkdir(os.path.join('png', day)) png_file = os.path.join('png', day, '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) page.save(png_file, quality=75) tools.print_image(png_file)
def process(infile, group_name, timeid): page = Image.open("infiles/" + infile) photo_size = (A4_WIDTH * 3 / 4, A4_HEIGHT * 3 / 4) photo_left = (A4_WIDTH - photo_size[0]) / 2 photo_top = (A4_HEIGHT - photo_size[1]) / 2 - A4_HEIGHT / 64 photo_right = photo_left + photo_size[0] photo_bottom = photo_top + photo_size[1] photo_rect = (photo_left, photo_top, photo_right, photo_bottom) create_title(page, (A4_WIDTH, A4_HEIGHT), photo_rect, group_name) day = tools.get_day() if not os.path.exists("png/{}".format(day)): os.mkdir("png/{}".format(day)) png_file = "png/{}_{}.jpg".format(timeid, tools.safe_filename(group_name)) page.save(png_file, quality=75) tools.print_image(png_file)
def on_process(self, _event): if self.validate(): day = tools.get_day() timeid = time.strftime('%H%M%S', time.localtime()) infile = self.names[self.index] infile_path = os.path.join('infiles', infile) group_name = self.group_name.GetValue() num_copies = self.num_copies.GetValue() if num_copies != '': process.process(infile_path, group_name, day, timeid, int(num_copies)) # pylint: disable=too-many-function-args else: process.process(infile_path, group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) outfile_path = os.path.join('outfiles', day, outfile_name) os.rename(infile_path, outfile_path) self.load_next_image()
def on_process(self, _event): if self.validate(): if self.keep_timeid.GetValue(): day = os.path.basename(os.path.dirname(self.filename)) timeid = os.path.basename(self.filename)[0:6] else: day = tools.get_day() timeid = time.strftime('%H%M%S', time.localtime()) infile = self.filename group_name = self.group_name.GetValue() num_copies = self.num_copies.GetValue() if num_copies != '': process.process(infile, group_name, day, timeid, int(num_copies)) # pylint: disable=too-many-function-args else: process.process(infile, group_name, day, timeid) out_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) out_path = os.path.join('outfiles', day, out_name) shutil.copyfile(self.filename, out_path)
def run(): if not tools.mount_camera(): print 'Could not connect to camera. Try again.' tools.get_camera_files() if tools.umount_camera(): print 'You can disconnect the camera now.' else: print 'Could not disconnect from camera.' names = os.listdir('infiles') names.sort() day = tools.get_day() if not os.path.exists(os.path.join('outfiles', day)): os.mkdir(os.path.join('outfiles', day)) for infile in names: group_name = raw_input('Group name: ') timeid = time.strftime('%H%M%S', time.localtime()) process(os.path.join('infiles', infile), group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name)) print 'Finished.'
def run(): if not tools.mount_camera(): print 'Could not connect to camera. Try again.' tools.get_camera_files() if tools.umount_camera(): print 'You can disconnect the camera now.' else: print 'Could not disconnect from camera.' names = os.listdir('infiles') names.sort() day = tools.get_day() tools.mkdir_p(os.path.join('outfiles', day)) for infile in names: group_name = raw_input('Group name: ') timeid = time.strftime('%H%M%S', time.localtime()) process(os.path.join('infiles', infile), group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name)) print 'Finished.'