def METHOD_NAME(variant_scalar_rgb, file_format, tmpdir):
    """
    Create a test image. Develop it to a few file format, each time reading
    it back and checking that contents are unchanged.
    """
    import numpy as np
    rng = np.random.default_rng(seed=12345 + ord(file_format[0]))
    # Note: depending on the file format, the alpha channel may be automatically removed.
    film = mi.load_dict({
        'type': 'hdrfilm',
        'width': 41,
        'height': 37,
        'file_format': file_format,
        'pixel_format': "rgba",
        'component_format': "float32",
        'filter': {'type': 'box'}
    })
    # Regardless of the output file format, values are stored as RGBAW (5 channels).
    contents = rng.uniform(size=(film.size()[1], film.size()[0], 5))
    # RGBE and will only reconstruct well images that have similar scales on
    # all channel (because exponent is shared between channels).
    if file_format == "rgbe":
        contents = 1 + 0.1 * contents
    # Use unit weights.
    contents[:, :, 4] = 1.0
    block = mi.ImageBlock(film.size(), [0, 0], 5, film.rfilter())
    for x in range(film.size()[1]):
        for y in range(film.size()[0]):
            block.put([y+0.5, x+0.5], contents[x, y, :])
    film.prepare([])
    film.put_block(block)
    filename = str(tmpdir.join('test_image.' + file_format))
    film.write(filename)
    # Read back and check contents
    other = mi.Bitmap(filename).convert(mi.Bitmap.PixelFormat.RGBAW, mi.Struct.Type.Float32, srgb_gamma=False)
    img   = mi.TensorXf(other)
    if False:
        import matplotlib.pyplot as plt
        plt.figure()
        plt.subplot(1, 3, 1)
        plt.imshow(contents[:, :, :3])
        plt.subplot(1, 3, 2)
        plt.imshow(img[:, :, :3])
        plt.subplot(1, 3, 3)
        plt.imshow(dr.sum(dr.abs(img[:, :, :3] - contents[:, :, :3]), axis=2), cmap='coolwarm')
        plt.colorbar()
        plt.show()
    if file_format == "exr":
        assert dr.allclose(img, contents, atol=1e-5)
    else:
        if file_format == "rgbe":
            assert dr.allclose(img[:, :, :3], contents[:, :, :3], atol=1e-2), \
                   '\n{}\nvs\n{}\n'.format(img[:4, :4, :3], contents[:4, :4, :3])
        else:
            assert dr.allclose(img[:, :, :3], contents[:, :, :3], atol=1e-5)
        # Alpha channel was ignored, alpha and weights should default to 1.0.
        assert dr.allclose(img[:, :, 3:5], 1.0, atol=1e-6)