Dask image array to jpg

Hi all, I’m new to dask and working with large tiff histology breast cancer images (2 to 10 GB) and I have two questions:

  1. Need to convert the tiff images to jpg. However, when saving the array using PIL imsave, I quickly run out of memory (80GB) and script crashes. Is there a way to use dask-image to save the image (png or jpg format) in small chunks that won’t chew up memory?
  2. When reading a tiff image using dask_image, how do I select the level of the image to extract? As you may know, a tiff image is setup in a pyramid manner, where the least resolution image on top, and the largest at the bottom
    Thank you in advance!

from dask_image.imread import imread
stack = imread(‘/path/to/experiment/large_image.tif’)