Skip to content

Conversation

@melissalinkert
Copy link
Member

Fixes #117.

Intentionally not added to ExampleSuite as this requires real data to run and cannot be used with fake input data.

Copy link
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

Tested by updating pom.xml to use formats-gpl, downloading CMU-1.svs from the public OME or OpenSlide image and running

mvn exec:java -Dexec.mainClass=PrecompressedTileReaderWriter -Dexec.arguments="CMU-1.svs,CMU-1.ome.tiff"

The command failed with

[WARNING] 
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:829)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
    at loci.formats.out.PyramidOMETiffWriter.close (PyramidOMETiffWriter.java:156)
    at PrecompressedTileReaderWriter.cleanup (PrecompressedTileReaderWriter.java:199)
    at PrecompressedTileReaderWriter.main (PrecompressedTileReaderWriter.java:225)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
    at java.lang.Thread.run (Thread.java:829)

The command-line equivalent completes without exception

bfconvert CMU-1.svs CMU-1.ome.tiff -precompressed -noflat

Copy link
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

With the last commit and the local change to pom.xml to depend on formats-gpl

sbesson@Sebastien-GS-MacBook-Pro-2025 bio-formats-examples % mvn exec:java -Dexec.mainClass=PrecompressedTileReaderWriter -Dexec.arguments="CMU-1.svs,CMU-1.ome.tiff"

[INFO] Scanning for projects...
[WARNING] The project ome:bio-formats-examples:jar:8.4.0-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[INFO] 
[INFO] ----------------------< ome:bio-formats-examples >----------------------
[INFO] Building Bio-Formats examples 8.4.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> exec:1.2.1:java (default-cli) > validate @ bio-formats-examples >>>
[INFO] 
[INFO] --- build-helper:3.0.0:parse-version (parse-version) @ bio-formats-examples ---
[INFO] 
[INFO] <<< exec:1.2.1:java (default-cli) < validate @ bio-formats-examples <<<
[INFO] 
[INFO] 
[INFO] --- exec:1.2.1:java (default-cli) @ bio-formats-examples ---
Cannot use precompressed tiles for series 1, resolution 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  15.763 s
[INFO] Finished at: 2025-11-25T11:51:37Z
[INFO] ------------------------------------------------------------------------
tiffinfo CMU-1.ome.tiff 
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
=== TIFF directory 0 ===
TIFF Directory at offset 0x10 (16)
  Image Width: 46000 Image Length: 32914
  Tile Width: 256 Tile Length: 256
  Resolution: 20040.1, 20040.1 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  SubIFD Offsets: 164157159 182426665
  ImageDescription: <?xml version="1.0" encoding="UTF-8"?><!-- Warning: this comment is an OME-XML metadata block, which contains crucial dimensional parameters and other important metadata. Please edit cautiously (if at all), and back up the original data before doing so. For more information, see the OME-TIFF web site: https://docs.openmicroscopy.org/latest/ome-model/ome-tiff/. --><OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Creator="OME Bio-Formats 8.3.0" UUID="urn:uuid:c5d9e33f-9e21-40a2-b6b8-4b47dd8e4c77" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"><Instrument ID="Instrument:0"><Objective ID="Objective:0:0" NominalMagnification="20.0"/></Instrument><Image ID="Image:0" Name=""><AcquisitionDate>2009-12-29T09:59:15</AcquisitionDate><Description>Aperio Image Library v10.0.51</Description><InstrumentRef ID="Instrument:0"/><ObjectiveSettings ID="Objective:0:0"/><Pixels BigEndian="false" DimensionOrder="XYCZT" ID="Pixels:0" Interleaved="false" PhysicalSizeX="0.499" PhysicalSizeXUnit="µm" PhysicalSizeY="0.499" PhysicalSizeYUnit="µm" SignificantBits="8" SizeC="3" SizeT="1" SizeX="46000" SizeY="32914" SizeZ="1" Type="uint8"><Channel ID="Channel:0:0" SamplesPerPixel="3"><LightPath/></Channel><TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1"><UUID FileName="CMU-1.ome.tiff">urn:uuid:c5d9e33f-9e21-40a2-b6b8-4b47dd8e4c77</UUID></TiffData><Plane PositionX="25.691574" PositionXUnit="mm" PositionY="23.449873" PositionYUnit="mm" TheC="0" TheT="0" TheZ="0"/></Pixels></Image><Image ID="Image:1" Name="label image"><AcquisitionDate>2009-12-29T09:59:15</AcquisitionDate><Description>label 387x463</Description><InstrumentRef ID="Instrument:0"/><ObjectiveSettings ID="Objective:0:0"/><Pixels BigEndian="false" DimensionOrder="XYCZT" ID="Pixels:1" Interleaved="false" SignificantBits="8" SizeC="3" SizeT="1" SizeX="387" SizeY="463" SizeZ="1" Type="uint8"><Channel ID="Channel:1:0" SamplesPerPixel="3"><LightPath/></Channel><TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="1" PlaneCount="1"><UUID FileName="CMU-1.ome.tiff">urn:uuid:c5d9e33f-9e21-40a2-b6b8-4b47dd8e4c77</UUID></TiffData><Plane TheC="0" TheT="0" TheZ="0"/></Pixels></Image><Image ID="Image:2" Name="macro image"><AcquisitionDate>2009-12-29T09:59:15</AcquisitionDate><Description>macro 1280x431</Description><InstrumentRef ID="Instrument:0"/><ObjectiveSettings ID="Objective:0:0"/><Pixels BigEndian="false" DimensionOrder="XYCZT" ID="Pixels:2" Interleaved="false" SignificantBits="8" SizeC="3" SizeT="1" SizeX="1280" SizeY="431" SizeZ="1" Type="uint8"><Channel ID="Channel:2:0" SamplesPerPixel="3"><LightPath/></Channel><TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="2" PlaneCount="1"><UUID FileName="CMU-1.ome.tiff">urn:uuid:c5d9e33f-9e21-40a2-b6b8-4b47dd8e4c77</UUID></TiffData><Plane TheC="0" TheT="0" TheZ="0"/></Pixels></Image><StructuredAnnotations><MapAnnotation ID="Annotation:Resolution:0" Namespace="openmicroscopy.org/PyramidResolution"><Value><M K="1">11500 8228</M><M K="2">2875 2057</M></Value></MapAnnotation></StructuredAnnotations></OME>
  Software: OME Bio-Formats 8.3.0
--- SubIFD image descriptor tag within TIFF directory 0 with array of 2 SubIFD chains ---
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
--- SubIFD 0 of chain 0 at offset 0x9c8d6e7 (164157159):
TIFF Directory at offset 0x9c8d6e7 (164157159)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 11500 Image Length: 8228
  Tile Width: 256 Tile Length: 256
  Resolution: 20040.1, 20040.1 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
--- SubIFD 1 of chain 0 at offset 0x9c8d6e7 (164157159):
TIFF Directory at offset 0xadf9c29 (182426665)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 2875 Image Length: 2057
  Tile Width: 256 Tile Length: 256
  Resolution: 20040.1, 20040.1 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
--- SubIFD 2 of chain 0 at offset 0x9c8d6e7 (164157159):
TIFF Directory at offset 0xaf97744 (184121156)
  Image Width: 387 Image Length: 463
  Tile Width: 384 Tile Length: 16
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: separate image planes
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
--- SubIFD 3 of chain 0 at offset 0x9c8d6e7 (164157159):
TIFF Directory at offset 0xafb9e5c (184262236)
  Image Width: 1280 Image Length: 431
  Tile Width: 1280 Tile Length: 16
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
--- SubIFD 0 of chain 1 at offset 0xadf9c29 (182426665):
TIFF Directory at offset 0xadf9c29 (182426665)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 2875 Image Length: 2057
  Tile Width: 256 Tile Length: 256
  Resolution: 20040.1, 20040.1 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
--- SubIFD 1 of chain 1 at offset 0xadf9c29 (182426665):
TIFF Directory at offset 0xaf97744 (184121156)
  Image Width: 387 Image Length: 463
  Tile Width: 384 Tile Length: 16
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: separate image planes
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
--- SubIFD 2 of chain 1 at offset 0xadf9c29 (182426665):
TIFF Directory at offset 0xafb9e5c (184262236)
  Image Width: 1280 Image Length: 431
  Tile Width: 1280 Tile Length: 16
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].

=== TIFF directory 1 ===
TIFF Directory at offset 0xaf97744 (184121156)
  Image Width: 387 Image Length: 463
  Tile Width: 384 Tile Length: 16
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: separate image planes
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0

JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].
=== TIFF directory 2 ===
TIFF Directory at offset 0xafb9e5c (184262236)
  Image Width: 1280 Image Length: 431
  Tile Width: 1280 Tile Length: 16
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: ImageJ=
hyperstack=true
images=3
channels=3
slices=1
frames=1
  Software: OME Bio-Formats 8.3.0

@sbesson sbesson merged commit 1e4408b into master Nov 25, 2025
50 checks passed
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.

Add precompressed tile example

3 participants