Convert .cbf to lossless image format with defined "dynamic range" We collected electron diffraction data and converted the data into .cbf (Crystallographic Binary File). Those are about 10'000 files. Now I would like to convert the .cbf into an image format like .tif but with a specified dynamic range.

I tried it with fabIO which is a python module. But I could not figure out how to successfully convert .cbf into .tif. .edf worked but it's not the  desired format. Also I don't know how to pick the dynamic range.

Maybe it is possible to use Adxv in the command line? I've been using it to export .tif but was only able to do so one by one.

What follows is my python script to convert .cbf into .edf:

import os
from glob import glob
import fabio

path = '/Users/myuser/Documents/Crystals'

result = [y for x in os.walk(path) for y in glob(os.path.join(x[0], '*.cbf'))]

i = 0
text = ''
while i &lt; len(result):

    if i == 4000:
        image = fabio.open(result[i])
        image.convert("edf").save("4000.edf")

    i += 1



Do you know how to use fabIO in order to export .tif with specific dynamic range? Or do you maybe know how to use Adxv in the command line in order to process many images? Or maybe you have another solution?
import os
from glob import glob
import fabio

path = '/Users/myuser/Documents/Crystals'

result = [y for x in os.walk(path) for y in glob(os.path.join(x[0], '*.cbf'))]

i = 0
command = ''
while i &lt; len(result):

    path = os.path.dirname(result[i])
    filename = os.path.splitext(result[i])[0]+'.tif'

    command = '/Applications/Adxv.app/Contents/MacOS/Adxv -smv32bits -sa -overload 500 '+result[i]+' '+filename
    os.system(command)

    i += 1



In the end I figured it out using Adxv in stand alone -sa and -overload N as dynamic range.