Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFConvert: Ensure crop size is used for all series #4003

Merged
merged 2 commits into from
Jun 7, 2023

Conversation

dgault
Copy link
Member

@dgault dgault commented May 10, 2023

This PR is in response to an issue reported on https://forum.image.sc/t/bfconvert-throwing-an-error-for-an-vsi-file/37185/7

I was able to reproduce the same exception with Bio-Formats 6.13.0 and the file from https://downloads.openmicroscopy.org/images/OME-TIFF/2016-06/sub-resolutions/Brightfield/Leica-1/

Without this PR, running the below command will result in an exception:

bfconvert -crop 0,0,512,512 Leica-1.ome.tiff Leica-1-crop.ome.tiff

Switching to BigTIFF (by file size)
	Series 0: converted 1/1 planes (100%)
Exception in thread "main" loci.formats.FormatException: Buffer is too small; expected 1414404 bytes, got 620544 bytes.
	at loci.formats.FormatWriter.checkParams(FormatWriter.java:476)
	at loci.formats.out.TiffWriter.saveBytes(TiffWriter.java:229)
	at loci.formats.out.OMETiffWriter.saveBytes(OMETiffWriter.java:219)
	at loci.formats.out.PyramidOMETiffWriter.saveBytes(PyramidOMETiffWriter.java:89)
	at loci.formats.out.OMETiffWriter.saveBytes(OMETiffWriter.java:209)
	at loci.formats.FormatWriter.saveBytes(FormatWriter.java:132)
	at loci.formats.ImageWriter.saveBytes(ImageWriter.java:252)
	at loci.formats.tools.ImageConverter.convertPlane(ImageConverter.java:830)
	at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:753)
	at loci.formats.tools.ImageConverter.main(ImageConverter.java:1186)

This is due to ImageConverter failing to correctly set the adjusted cropped dimensions for any series other than the first.

To test, rerun the above scenario and the conversion should complete without exception. The converted file should be able to open and display, with the correct cropped dimensions being used for each series.

@dgault dgault added this to the 6.13.1 milestone May 10, 2023
@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/bfconvert-throwing-an-error-for-an-vsi-file/37185/9

@melissalinkert melissalinkert self-requested a review May 10, 2023 13:56
@melissalinkert
Copy link
Member

#3630 might be related.

Copy link
Member

@melissalinkert melissalinkert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. There is still an exception with something like bfconvert -noflat -crop 0,0,512,512 Leica-1.ome.tiff crop-test.ome.tiff, but that's covered by #3630 and out of scope for this PR. I'm fine with this being merged for 6.13.1.

@dgault dgault merged commit e08210a into ome:develop Jun 7, 2023
@melissalinkert melissalinkert modified the milestones: 6.13.1, 6.14.0 Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants