Compression or quality values for PNG and JPEG file types can be set for saving rendered images like this:
bpy.context.scene.render.image_settings.compression = 55
However when it comes to saving images (not renders, but just regular image files within your .blend file) you seem to be able to control aspects such as file format, but I’ve not found in the API where you might be able to set the compression or quality values. For instance you can set the file format like this:
bpy.data.images['MyImage'].file_format = 'JPEG'
Code tips reveal “ImageFormatSettings.compression” on the compression value when you go to save an image from the Image Editor, but neither “ImageFormatSettings.compression” nor “image_settings.compression” seem to be a property of images. Does anyone know how to change this value via Python?