def menu_saveScript(self): filename = tkutil_dialog.ask_savefile(title = 'Save Script',types=['.pyx|Scripts']) if not filename: return f = open(filename, 'w') f.write(tkutil.gettext(self.fldScript)) f.close() print 'Script saved to ',filename
def menu_saveImage(self): if self.imgOutput==None: print 'No output image.' return filename = tkutil_dialog.ask_savefile(title = 'Save Image',types=['.png|Png image','.bmp|Bitmap image','.jpg|Jpeg image','.tif|TIFF image']) if not filename: return self.imgOutput.save(filename) print 'Image saved to ',filename
def menu_saveScript(self): filename = tkutil_dialog.ask_savefile(title='Save Script', types=['.pyx|Scripts']) if not filename: return f = open(filename, 'w') f.write(tkutil.gettext(self.fldScript)) f.close() print('Script saved to ', filename)
def menu_batch(self): import os filename = tkutil_dialog.ask_openfile( title="Choose representative file (same directory, type).") if not filename: return if '.' not in filename: print('Could not find extension.') return path, filename = os.path.split(filename) ext = filename.split('.')[-1] files = [file for file in os.listdir(path) if file.endswith('.' + ext)] outputfilename = tkutil_dialog.ask_savefile( title='Choose directory and format of output images.', types=[ '.png|Png image', '.bmp|Bitmap image', '.jpg|Jpeg image', '.tif|TIFF image' ]) outputpath, outputfilename = os.path.split(outputfilename) outputext = outputfilename.split('.')[-1] confirm = tkutil_dialog.ask_okcancel('Run current script on ' + str(len(files)) + ' files of type .' + ext + ' in directory ' + path + '?') if not confirm: return for file in files: filename = os.path.join(path, file) outputfilename = os.path.join(outputpath, file[0:-len(ext)] + outputext) if os.path.exists(outputfilename): print('Skipped: File already exists:', outputfilename) continue try: im = Image.open(filename) im.load() except: print('Skipped: Could not open image.') continue imgResult = runScript(tkutil.gettext(self.fldScript), im) if imgResult == None: print('Skipped: Script error.') continue try: imgResult.save(outputfilename) except: print('Error. Could not save ', outputfilename) print('Saved: ' + outputfilename) print('Job complete.')
def menu_saveImage(self): if self.imgOutput == None: print('No output image.') return filename = tkutil_dialog.ask_savefile(title='Save Image', types=[ '.png|Png image', '.bmp|Bitmap image', '.jpg|Jpeg image', '.tif|TIFF image' ]) if not filename: return self.imgOutput.save(filename) print('Image saved to ', filename)
def menu_batch(self): import os filename = tkutil_dialog.ask_openfile(title="Choose representative file (same directory, type).") if not filename: return if '.' not in filename: print 'Could not find extension.' return path, filename = os.path.split(filename) ext = filename.split('.')[-1] files = [file for file in os.listdir(path) if file.endswith('.'+ext)] outputfilename = tkutil_dialog.ask_savefile(title = 'Choose directory and format of output images.',types=['.png|Png image','.bmp|Bitmap image','.jpg|Jpeg image','.tif|TIFF image']) outputpath, outputfilename = os.path.split(outputfilename) outputext = outputfilename.split('.')[-1] confirm = tkutil_dialog.ask_okcancel('Run current script on '+str(len(files))+' files of type .'+ext +' in directory '+path+'?') if not confirm: return for file in files: filename = os.path.join(path, file) outputfilename = os.path.join( outputpath, file[0:-len(ext)] + outputext) if os.path.exists(outputfilename): print 'Skipped: File already exists:', outputfilename continue try: im = Image.open(filename) im.load() except: print 'Skipped: Could not open image.' continue imgResult = runScript(tkutil.gettext(self.fldScript), im) if imgResult==None: print 'Skipped: Script error.' continue try: imgResult.save(outputfilename) except: print 'Error. Could not save ',outputfilename print 'Saved: '+outputfilename print 'Job complete.'