How to Change Image Saving Options with the Python API? (Color, Color Depth) In my script I create an image, generate the image and then save it like this: 

image = bpy.data.images.new('my_image', width=1024, height=1024)
# other code that generates the image by baking onto a texture node ...
image.filepath_raw = '//outputs/my_image.tif'
image.file_format = 'TIFF'
image.save()


But when saving the image I would like to have control over those options:



...which are available when saving from the user interface.
You can discover nearly all data paths from Blender GUI itself.

Set your mouse cursor over a field and a tooltip will appear:



You can also copy (part of) the path directly here:



Then you can use it (and test it) from the Python console, and also discover all the properties you need using autocompletion with the Tab key:



So concretely you can for instance:

bpy.context.scene.render.image_settings.color_mode = 'RGBA'
bpy.context.scene.render.image_settings.color_depth = '8'
bpy.context.scene.render.image_settings.compression = 20


You can now easily search in the documentation:



And have access to a complete information for the fields values (click me).