Changeset 201

Show
Ignore:
Timestamp:
Mon Apr 7 12:48:37 2008
Author:
manatlan
Message:

- extract now ONLY real dates from jhead (tools.py)

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/tools.py

    r187 r201  
    184 184         """  
    185 185           prepare the file (rename/rotate according exif) ... (in one jhead action (optimization))  
    186              
      186  
    186 186           if needRename :  
    187 187             rename file according its exifdate, and set datefile = date exif,  
    188 188             and return the new name (or old one if not renamed)  
    189                
      189  
    189 189           and do autorot according exif tag if "needAutoRot" is True  
    190 190         """  
    191            
      191  
    191 191         if _Command.isWin:  
    192 192             needAutoRot = False # no autorotate on windows (jpegtran trouble)  
    193            
      193  
    193 193         if needRename:  
    194 194             # renaming is needed, we'll need to return the new name  
     
    202 202                 buf = _Command._run( [_Command.__jhead,'-ft',"-nf"+_Command.format,file] )  
    203 203  
    204               # rename has be done, we need to get the newname       
      204             # rename has be done, we need to get the newname  
    204 204             # (we get it in jhead output)  
    205 205             p = buf.find("-->")  
     
    211 211                # not renamed, return original name  
    212 212                return file  
    213                
      213  
    213 213         else:  
    214 214             # no renaming, return the original filename (to be compatible)  
    215 215             if needAutoRot:  
    216 216                 _Command._run( [_Command.__jhead,"-ft","-autorot",file] )  
    217                    
      217  
    217 217             return file  
    218            
      218  
    218 218    #----------------------------------------------------------------------------  
    219 219    @staticmethod  
     
    233 233  
    234 234       try:  
    235             tag["filedate"] = re.findall( "File date    : (.*)", buf )[0].strip()  
      235           tag["filedate"] = re.findall( "File date    : (\d\d\d\d:\d\d:\d\d \d\d:\d\d:\d\d)", buf )[0].strip()  
    235 235           tag["resolution"] = re.findall( "Resolution   : (.*)", buf )[0].strip()  
    236 236       except:  
    237 237           raise CommandException( "Exif decoding trouble in "+file +"\n"+buf)  
    238 238  
    239    
    240 239       # try to get exif info (from jhead)  
    241 240       try:  
    242            exifdate   = re.findall( "Date/Time    : (.*)", buf )[0].strip()  
      241          exifdate   = re.findall( "Date/Time    : (\d\d\d\d:\d\d:\d\d \d\d:\d\d:\d\d)", buf )[0].strip()  
    242 241          isflash    = re.findall( "Flash used   : (.*)", buf )[0].strip()  
    243 242       except IndexError:  
     
    551 550         """  
    552 551         assert type(file)==unicode  
    553            
      552  
    553 552         return _Command.prepareFile(file,needRename=True,needAutoRot=False)  
    554 553  
     
    570 569         """ set format for normalized files (see prepareFile())"""  
    571 570         _Command.format = format  
    572            
    573            
      571  
      572  
    574 573    def __init__(self,file):  
    575 574       assert type(file)==unicode,"ERROR:"+str(type(file))  
     
    779 778  
    780 779     #~ test_Command(f)  
      780  
      781     buf="""  
      782 Camera make  : FUJIFILM  
      783 Camera model : FinePix F11  
      784 Date/Time    : 2008:03:28 21:23:41  
      785 Resolution   : 2048 x 1536  
      786 Flash used   : Yes (auto)  
      787  
      788  
      789     """  
      790     print re.findall( "Date/Time    : (\d\d\d\d:\d\d:\d\d \d\d:\d\d:\d\d)", buf )[0].strip()