Skip to content

Commit

Permalink
Add an option to compression to webp lossless.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Jan 21, 2021
1 parent fee9ed9 commit 7bf2600
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def testIsVips():
({'compression': 'lzw', 'predictor': 'yes'}, {
tifftools.Tag.Compression.value: tifftools.constants.Compression.LZW.value
}),
({'compression': 'webp', 'quality': 0}, {
tifftools.Tag.Compression.value: tifftools.constants.Compression.WEBP.value
}),
({'tileSize': 512}, {
tifftools.Tag.TileWidth.value: 512
}),
Expand Down
2 changes: 2 additions & 0 deletions utilities/converter/large_image_converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ def _vips_parameters(forTiled=True, **kwargs):
convertParams[vkey] = kwargs[kwkey]
if convertParams['compression'] == 'jp2k':
convertParams['compression'] = 'none'
if convertParams['compression'] == 'webp' and kwargs.get('quality') == 0:
convertParams['lossless'] = True
if convertParams['predictor'] == 'yes':
convertParams['predictor'] = 'horizontal'
if convertParams['compression'] == 'jpeg':
Expand Down
3 changes: 2 additions & 1 deletion utilities/converter/large_image_converter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def get_parser():
'compression ratio.')
parser.add_argument(
'--quality', '-q', default=90, type=int,
help='JPEG compression quality')
help='JPEG or webp compression quality. For webp, specify 0 for '
'lossless.')
parser.add_argument(
'--level', '-l', type=int,
help='General compression level. Used for deflate (zip), zstd, and '
Expand Down

0 comments on commit 7bf2600

Please sign in to comment.