Skip to content

Commit

Permalink
Merge pull request #545 from girder/converter
Browse files Browse the repository at this point in the history
Improve help text.
  • Loading branch information
manthey authored Feb 17, 2021
2 parents c551482 + 60ee5e6 commit 0232acc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 7 additions & 3 deletions utilities/converter/large_image_converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ def _generate_geotiff(inputPath, outputPath, **kwargs):
cmdopt += ['-co', 'LEVEL=%s' % options['level']]
cmd = ['gdal_translate', inputPath, outputPath] + cmdopt
logger.info('Convert to geotiff: %r' % (cmd))
# subprocess.check_call(cmd)
ds = gdal.Open(inputPath, gdalconst.GA_ReadOnly)
gdal.Translate(outputPath, ds, options=cmdopt)
try:
# subprocess.check_call(cmd)
ds = gdal.Open(inputPath, gdalconst.GA_ReadOnly)
gdal.Translate(outputPath, ds, options=cmdopt)
except Exception:
os.unlink(outputPath)
raise


def _generate_multiframe_tiff(inputPath, outputPath, tempPath, lidata, **kwargs):
Expand Down
16 changes: 14 additions & 2 deletions utilities/converter/large_image_converter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@


def get_parser():
parser = argparse.ArgumentParser(description='Large Image image converter')
parser = argparse.ArgumentParser(description="""
Convert files for use with Large Image.
Output files are written as tiled tiff files. For geospatial files, these
conform to the cloud-optimized geospatial tiff format (COG). For
non-geospatial, the output image will be either 8- or 16-bits per sample per
channel. Some compression formats are always 8-bits per sample (webp, jpeg),
even if that format could support more and the original image is higher bit
depth.
""")
parser.add_argument(
'--version', action='version',
version=large_image_converter.__version__, help='Report version')
Expand Down Expand Up @@ -202,7 +210,11 @@ def main(args=sys.argv[1:]):
import tifftools.commands

info = tifftools.read_tiff(dest)
desc = json.loads(info['ifds'][0]['tags'][tifftools.Tag.ImageDescription.value]['data'])
try:
desc = json.loads(info['ifds'][0]['tags'][tifftools.Tag.ImageDescription.value]['data'])
except Exception:
logger.debug('Cannot generate statistics.')
return
desc['large_image_converter']['conversion_stats'] = {
'time': end_time - start_time,
'filesize': os.path.getsize(dest),
Expand Down

0 comments on commit 0232acc

Please sign in to comment.