Skip to content

How to set bit depth when saving files?  #260

@orswan

Description

@orswan

I am trying to save a bitmap with a specific bit depth. However, regardless of the type of an image, when I save it as a bitmap, it ends up with bit depth 24. I cannot find anything in the documentation when I search for "bit depth". How can I accomplish this?

A minimal working example is as follows:

using Images, FileIO
#dir = "/path/to/dir"
im_large = n0f16.(Gray.(rand(100,100)))
save(dir * "large.bmp",im_large)
im_small = n0f8.(Gray.(rand(100,100)))
save(dir * "small.bmp",im_small)

Both saved bmp files end up having bit depth 24 on my system (Windows 10).

Edit: It seems that this issue has to do with the number of channels. Even though my images above are supposedly greyscale, the images are saved with three color channels (all having equal values). An 8-bit bmp should have just a single channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions