Skip to content

Image.save_png_to_buffer() should have flag to preserve data format #12752

Closed
@blackears

Description

@blackears

Describe the project you are working on

Medical image data visualization.

Describe the problem or limitation you are having in your project

The default behaviour of Image.save_png_to_buffer() will always save image data in RGBA8 format, regardless of the data format of the image itself. Since PNG can handle 32 bit floating point images, it would be helpful to add a flag to indicate that the buffer format should preserved as much as possible. I'm mostly working with FORMAT_RF and FORMAT_RGBAF images, so saving to PNG is essentially destroying my data (in particular - negative values, which aren't preserved in RGBA8).

Also, I can't use EXR since there is no Image.load_exr_from_buffer() method.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a flag to indicate to this method to indicate that the data format should be preserved when writing the data.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

You could add a parameter like Image.save_png_to_buffer(preserve_format:bool = false)

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

Requires changing how buffers are written.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions