[gdal-dev] Configuring JP2OpenJPEG attributes

Even Rouault even.rouault at spatialys.com
Thu Oct 22 01:24:24 PDT 2015


Basos,

> 1) When I run the commands:Raster =
> gdal.Open(tiffile)jpg_driver = gdal.GetDriverByName('JP2OpenJPEG')
> jpg_driver.Register()jpg_file = jpg_driver.CreateCopy(outjp2file, Raster,
> options = ['QUALITY=100', 'REVERSIBLE=YES']) 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:Raster = gdal.Open(outjp2file)
> driver = Raster.GetDriver()
> metadata = driver.GetMetadata()

You get driver metadata here, that is to say the capabilities of the driver, 
not the charactersitics of a particular dataset.

> print driver.GetMetadataItem('QUALITY')None
> print driver.GetMetadataItem('QUALITY', 'IMAGE_STRUCTURE')None

If they were available as metadata (but they are not), that should be queried 
on the dataset, not the driver.

> 
> How can I retrieve the attributes 'QUALITY' and 'REVERSIBLE'?

You can't. At least not that easily. They aren't exposed as metadata when 
reading a dataset.
You can have a look at the dump_jp2 utility mentionned in 
https://trac.osgeo.org/gdal/wiki/UserDocs/JPEG2000Utils to get the 
reversive/reversible parameter, but I don't think it is possibly to recover 
quality (might be, but I'm not knowleadgable enough)

> 
> 2) If instead of using the command:jpg_file =
> jpg_driver.CreateCopy(outjp2file, Raster, options = ['QUALITY=100',
> 'REVERSIBLE=YES'])
> 
> I use the
> following:jpg_driver.SetMetadataItem('QUALITY','100','IMAGE_STRUCTURE')jpg
> _driver.SetMetadataItem('REVERSIBLE','YES','IMAGE_STRUCTURE')

No, that will not have the effect you want. Setting metadata on drivers is 
without effect. Using creation options like you did initially is the right way 
to do it.

> jpg_driver.Reg
> ister()jpg_file = jpg_driver.CreateCopy(outjp2file, Raster)
> 
> why these two attributes are set as primary keys and not in the options
> list? Thank you in advance.Basos
>  

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list