Changeset 14408

Show
Ignore:
Timestamp:
05/09/08 08:49:54 (2 months ago)
Author:
rouault
Message:

Add test for writing TIFF tags

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/autotest/gcore/tiff_write.py

    r14407 r14408  
    611611 
    612612    gdaltest.tiff_drv.Delete( 'tmp/contig_strip_7.tif' ) 
     613 
     614    return 'success' 
     615 
     616############################################################################### 
     617# Test write and read of some TIFF tags 
     618 
     619def tiff_write_20(): 
     620 
     621    new_ds = gdaltest.tiff_drv.Create( 'tmp/tags.tif', 1, 1, 1) 
     622 
     623    values = [ ('TIFFTAG_DOCUMENTNAME'    , 'document_name'), 
     624               ('TIFFTAG_IMAGEDESCRIPTION', 'image_description'), 
     625               ('TIFFTAG_SOFTWARE'        , 'software'), 
     626               ('TIFFTAG_DATETIME'        , 'datetime'), 
     627               ('TIFFTAG_ARTIST'          , 'artitst'), 
     628               ('TIFFTAG_HOSTCOMPUTER'    , 'host_computer'), 
     629               ('TIFFTAG_COPYRIGHT'       , 'copyright'), 
     630               ('TIFFTAG_XRESOLUTION'     , '100'), 
     631               ('TIFFTAG_YRESOLUTION'     , '101'), 
     632               ('TIFFTAG_RESOLUTIONUNIT'  , '2 (pixels/inch)'), 
     633             ] 
     634 
     635    dict = {} 
     636    for item in values: 
     637        dict[item[0]] = item[1] 
     638    new_ds.SetMetadata(dict) 
     639 
     640    new_ds = None 
     641 
     642    # hopefully it's closed now! 
     643 
     644    new_ds = gdal.Open( 'tmp/tags.tif' ) 
     645    md = new_ds.GetMetadata() 
     646    for item in values: 
     647        if not md.has_key(item[0]): 
     648            gdaltest.post_reason( 'Couldnt find tag %s' %(item[0])) 
     649            return 'fail' 
     650 
     651        if md[item[0]] != item[1]: 
     652            gdaltest.post_reason( 'For tag %s, got %s, expected %s' %(item[0], md[item[0]], item[1])) 
     653            return 'fail' 
     654 
     655    src_ds = None 
     656 
     657    gdaltest.tiff_drv.Delete( 'tmp/tags.tif' ) 
    613658 
    614659    return 'success' 
     
    639684    tiff_write_18, 
    640685    tiff_write_19, 
     686    tiff_write_20, 
    641687    tiff_write_cleanup ] 
    642688