Skip to content
3 changes: 2 additions & 1 deletion modules/bioformats2ometiff.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ process bioformats2ometiff {
touch "${image.simpleName}.ome.tiff"
"""
script:
def rgb_flag = meta.he ? '--rgb' : ''
"""
bioformats2raw $image 'raw_dir'
raw2ometiff 'raw_dir' "${image.simpleName}.ome.tiff"
raw2ometiff ${rgb_flag} 'raw_dir' "${image.simpleName}.ome.tiff"
"""
}
19 changes: 10 additions & 9 deletions modules/make_miniature.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ process make_miniature {
"""
#!/usr/bin/env python

from tiffslide import TiffSlide
import matplotlib.pyplot as plt
import os
import pyvips

slide = TiffSlide('$image')

thumb = slide.get_thumbnail((512, 512))
if thumb.mode in ("RGBA", "P"):
thumb = thumb.convert("RGB")
thumb.save('miniature.jpg')
# Use pyvips for robust thumbnail generation from any whole slide format
# Supports SVS, OME-TIFF, and other formats efficiently
slide = pyvips.Image.new_from_file('$image', access='sequential')

# Create thumbnail with max dimension of 512px
thumbnail = slide.thumbnail_image(512)

# Save as JPEG
thumbnail.write_to_file('miniature.jpg')
"""
} else {
"""
Expand Down
Loading