Changeset 103 for Xml/Validator/Backend/mateTiff.py
- Timestamp:
- 09/26/07 09:37:32 (16 months ago)
- Files:
-
- 1 modified
-
Xml/Validator/Backend/mateTiff.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Xml/Validator/Backend/mateTiff.py
r96 r103 15 15 help_message = ''' 16 16 This extracts the Description block [270] from the TIFF file and opens it 17 in the mate editor 17 in the mate editor then writes it back 18 18 ''' 19 19 … … 59 59 # read the xml from the tiff 60 60 theXml = image.tag[270] 61 # print "Processing file : %s\n" % aFilename62 # print theXml63 # print ""64 61 theNewXml = edited_text(theXml) 65 image.tag[270] = theNewXml 66 print "At present this destroys multi plane TIFF files - are you sure you want to save? y/n" 67 confirm = sys.stdin.readline()[:-1] 68 print 'confirm = \'%s\'' %(confirm) 69 if confirm in ['y', 'Y', 'Yes', 'YES', 'yes']: 70 print "Saving..." 71 image.save(aFilename) 72 print "done" 73 else: 74 print "Skipped" 75 62 write_tag_into_tiff(aFilename, theNewXml) 76 63 77 64 except Usage, err: … … 103 90 os.unlink(temp_filename) 104 91 return result 92 93 def write_tag_into_tiff(inTiffFilename, inXmlString): 94 temp_fd, temp_filename = tempfile.mkstemp(text=True) 95 os.write(temp_fd, inXmlString) 96 os.close(temp_fd) 97 x = os.spawnlp(os.P_WAIT, "java", "java", "EditTiff", inTiffFilename, temp_filename) 98 if x: 99 raise RuntimeError, "Can't run java EditTiff %s %s (%s)" % (inTiffFilename, temp_filename,x) 100 result = open(temp_filename).read() 101 os.unlink(temp_filename) 102 return result 105 103 106 104 if __name__ == "__main__":
