Skip to content

Commit

Permalink
Merge pull request #1195 from girder/convert-multiframe
Browse files Browse the repository at this point in the history
Fix converting multiframe files that vips reads as single frame
  • Loading branch information
manthey authored Jun 8, 2023
2 parents 9408b52 + 5908989 commit 33147c2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Refactor reading the .large_image_config.yaml file on the girder client ([#1193](../../pull/1193))
- Refactor of the which-folders-have-annotations pipeline ([#1194](../../pull/1194))

### Bug Fixes
- Fix an issue converting multiframe files that vips reads as single frame ([#1195](../../pull/1195))

## 1.22.2

### Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ else if largeImage && largeImage.expected === true
a.g-large-image-expected(title="A large image file is being generated")
i.icon-picture
else if !largeImage || !largeImage.fileId
a.g-large-image-create(title="Use this file for a large image")
a.g-large-image-create(title="Use this file for a large image. Ctrl-click to force converting the image before using it")
i.icon-picture
2 changes: 1 addition & 1 deletion girder/girder_large_image/web_client/views/fileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ wrap(FileListWidget, 'render', function (render) {
restRequest({
type: 'POST',
url: 'item/' + this.parentItem.id + '/tiles',
data: {fileId: fileId, notify: true},
data: {fileId: fileId, notify: true, force: !!(e.originalEvent || {}).ctrlKey},
error: function (error) {
if (error.status !== 0) {
events.trigger('g:alert', {
Expand Down
10 changes: 10 additions & 0 deletions test/test_converter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import shutil
import sys

import large_image_converter
import large_image_converter.__main__ as main
Expand Down Expand Up @@ -314,3 +315,12 @@ def testConvertFromTestSourceFrameArray(tmpdir):
assert len(metadata['frames']) == 6
info = tifftools.read_tiff(outputPath)
assert len(info['ifds']) == 6


@pytest.mark.skipif(sys.version_info < (3, 7), reason='requires python >= 3.7 for the test image')
def testConvertImageJ(tmpdir):
imagePath = datastore.fetch('synthetic_imagej.tiff')
outputPath = os.path.join(tmpdir, 'out.tiff')
large_image_converter.convert(imagePath, outputPath, compression='jpeg', quality=50)
info = tifftools.read_tiff(outputPath)
assert len(info['ifds']) == 44
4 changes: 3 additions & 1 deletion utilities/converter/large_image_converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,9 @@ def convert(inputPath, outputPath=None, **kwargs): # noqa: C901
lidata = _data_from_large_image(inputPath, tempPath, **kwargs)
logger.log(logging.DEBUG - 1, 'large_image information for %s: %r',
inputPath, lidata)
if not is_vips(inputPath) and lidata:
if lidata and (not is_vips(inputPath) or (
len(lidata['metadata'].get('frames', [])) >= 2 and
not _is_multiframe(inputPath))):
_convert_large_image(inputPath, outputPath, tempPath, lidata, **kwargs)
elif _is_multiframe(inputPath):
_generate_multiframe_tiff(inputPath, outputPath, tempPath, lidata, **kwargs)
Expand Down

0 comments on commit 33147c2

Please sign in to comment.