<html><head></head><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:16px"><div id="yui_3_16_0_1_1445495781671_8664" class="">Dear list members,</div><div id="yui_3_16_0_1_1445495781671_8666" class="" dir="ltr">I would like you to help me with two issues I have while trying to set/get the attributes of the JP2OpenJPEG driver through the GDAL API in Python:</div><div id="yui_3_16_0_1_1445495781671_8666" class="" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">1) When I run the commands:</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">Raster = gdal.Open(tiffile)</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_driver = gdal.GetDriverByName('JP2OpenJPEG')<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_driver.Register()</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_file = jpg_driver.CreateCopy(outjp2file, Raster, options = ['QUALITY=100', 'REVERSIBLE=YES'])</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">the attributes are set without problem (tiffile refers to a Geotiff image and outjp2file is the name of the new jp2 file); when I try to retrieve them the only thing I manage to do is to read the main keys:</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">Raster = gdal.Open(outjp2file)<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">driver = Raster.GetDriver()<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">metadata = driver.GetMetadata()</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">metadata</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">{'DMD_EXTENSION': 'jp2', 'DMD_CREATIONOPTIONLIST': "<CreationOptionList> <Option name='CODEC' type='string-select' default='according to file extension. If unknown, default to J2K'> <Value>JP2</Value> <Value>J2K</Value> </Option> <Option name='GeoJP2' type='boolean' description='Whether to emit a GeoJP2 box' default='YES'/> <Option name='GMLJP2' type='boolean' description='Whether to emit a GMLJP2 v1 box' default='YES'/> <Option name='GMLJP2V2_DEF' type='string' description='Definition file to describe how a GMLJP2 v2 box should be generated. If set to YES, a minimal instance will be created'/> <Option name='QUALITY' type='string' description='Single quality value or comma separated list of increasing quality values for several layers, each in the 0-100 range' default='25'/> <Option name='REVERSIBLE' type='boolean' description='True if the compression is reversible' default='false'/> <Option name='RESOLUTIONS' type='int' description='Number of resolutions.' min='1' max='30'/> <Option name='BLOCKXSIZE' type='int' description='Tile Width' default='1024'/> <Option name='BLOCKYSIZE' type='int' description='Tile Height' default='1024'/> <Option name='PROGRESSION' type='string-select' default='LRCP'> <Value>LRCP</Value> <Value>RLCP</Value> <Value>RPCL</Value> <Value>PCRL</Value> <Value>CPRL</Value> </Option> <Option name='SOP' type='boolean' description='True to insert SOP markers' default='false'/> <Option name='EPH' type='boolean' description='True to insert EPH markers' default='false'/> <Option name='YCBCR420' type='boolean' description='if RGB must be resampled to YCbCr 4:2:0' default='false'/> <Option name='YCC' type='boolean' description='if RGB must be transformed to YCC color space (lossless MCT transform)' default='YES'/> <Option name='NBITS' type='int' description='Bits (precision) for sub-byte files (1-7), sub-uint16 (9-15), sub-uint32 (17-31)'/> <Option name='1BIT_ALPHA' type='boolean' description='Whether to encode the alpha channel as a 1-bit channel' default='NO'/> <Option name='ALPHA' type='boolean' description='Whether to force encoding last channel as alpha channel' default='NO'/> <Option name='PROFILE' type='string-select' description='Which codestream profile to use' default='AUTO'> <Value>AUTO</Value> <Value>UNRESTRICTED</Value> <Value>PROFILE_1</Value> </Option> <Option name='INSPIRE_TG' type='boolean' description='Whether to use features that comply with Inspire Orthoimagery Technical Guidelines' default='NO'/> <Option name='JPX' type='boolean' description='Whether to advertize JPX features when a GMLJP2 box is written' default='YES'/> <Option name='GEOBOXES_AFTER_JP2C' type='boolean' description='Whether to place GeoJP2/GMLJP2 boxes after the code-stream' default='NO'/> <Option name='PRECINCTS' type='string' description='Precincts size as a string of the form {w,h},{w,h},... with power-of-two values'/> <Option name='TILEPARTS' type='string-select' description='Whether to generate tile-parts and according to which criterion' default='DISABLED'> <Value>DISABLED</Value> <Value>RESOLUTIONS</Value> <Value>LAYERS</Value> <Value>COMPONENTS</Value> </Option> <Option name='CODEBLOCK_WIDTH' type='int' description='Codeblock width' default='64' min='4' max='1024'/> <Option name='CODEBLOCK_HEIGHT' type='int' description='Codeblock height' default='64' min='4' max='1024'/> <Option name='CT_COMPONENTS' type='int' min='3' max='4' description='If there is one color table, number of color table components to write. Autodetected if not specified.'/> <Option name='WRITE_METADATA' type='boolean' description='Whether metadata should be written, in a dedicated JP2 XML box' default='NO'/> <Option name='MAIN_MD_DOMAIN_ONLY' type='boolean' description='(Only if WRITE_METADATA=YES) Whether only metadata from the main domain should be written' default='NO'/> <Option name='USE_SRC_CODESTREAM' type='boolean' description='When source dataset is JPEG2000, whether to reuse the codestream of the source dataset unmodified' default='NO'/></CreationOptionList>", 'DMD_HELPTOPIC': 'frmt_jp2openjpeg.html', 'DCAP_VECTOR': 'YES', 'DMD_OPENOPTIONLIST': "<OpenOptionList> <Option name='1BIT_ALPHA_PROMOTION' type='boolean' description='Whether a 1-bit alpha channel should be promoted to 8-bit' default='YES'/> <Option name='OPEN_REMOTE_GML' type='boolean' description='Whether to load remote vector layers referenced by a link in a GMLJP2 v2 box' default='NO'/></OpenOptionList>", 'DCAP_OPEN': 'YES', 'DCAP_RASTER': 'YES', 'DCAP_VIRTUALIO': 'YES', 'DMD_MIMETYPE': 'image/jp2', 'DMD_CREATIONDATATYPES': 'Byte Int16 UInt16 Int32 UInt32', 'DMD_EXTENSIONS': 'jp2 j2k', 'DCAP_CREATECOPY': 'YES', 'DMD_LONGNAME': 'JPEG-2000 driver based on OpenJPEG library'}<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">print driver.GetMetadataItem('QUALITY')</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">None</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">print driver.GetMetadataItem('QUALITY', 'IMAGE_STRUCTURE')</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">None</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">print driver.GetMetadataItem('DMD_CREATIONOPTIONLIST')</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><CreationOptionList> <Option name='CODEC' type='string-select' default='according to file extension. If unknown, default to J2K'> ......<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">How can I retrieve the attributes 'QUALITY' and 'REVERSIBLE'?</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">2) If instead of using the command:</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_file = jpg_driver.CreateCopy(outjp2file, Raster, options = ['QUALITY=100', 'REVERSIBLE=YES'])<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">I use the following:</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_driver.SetMetadataItem('QUALITY','100','IMAGE_STRUCTURE')</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_driver.SetMetadataItem('REVERSIBLE','YES','IMAGE_STRUCTURE')</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_driver.Register()</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">jpg_file = jpg_driver.CreateCopy(outjp2file, Raster)<br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">why these two attributes are set as primary keys and not in the options list?</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">Thank you in advance.</div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class="">Basos </div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""><br></div><div dir="ltr" id="yui_3_16_0_1_1445495781671_8668" class=""> </div></div></body></html>