• Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 103

Show
Ignore:
Timestamp:
09/26/07 09:37:32 (11 months ago)
Author:
andrew
Message:

First working version - mateTiff is very fragile. It has to use a seprate java application to add xml back into tiff.

Location:
Xml/Validator/Backend
Files:
1 added
1 modified

  • isValidOME.py (added)
  • mateTiff.py (modified) (3 diffs)

Legend:

Unmodified
Added
Removed
  • Xml/Validator/Backend/mateTiff.py

    r96 r103  
    1515help_message = ''' 
    1616This extracts the Description block [270] from the TIFF file and opens it  
    17 in the mate editor 
     17in the mate editor then writes it back 
    1818''' 
    1919 
    … …  
    5959                                    # read the xml from the tiff 
    6060                                        theXml = image.tag[270] 
    61                                         # print "Processing file : %s\n" % aFilename 
    62                                         # print theXml 
    63                                         # print "" 
    6461                                        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) 
    7663                 
    7764        except Usage, err: 
    … …  
    10390        os.unlink(temp_filename) 
    10491        return result 
     92 
     93def 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 
    105103         
    106104if __name__ == "__main__": 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/