Save image as 24 bit png

10,419

Solution 1

Your problem is that you don't understand the output of the file command. I used Paint.NET to save an image as 32-bit PNG, 24-bit PNG, and 8-bit PNG. Then I ran the file command on them:

$ file *bit.png
08-bit.png: PNG image data, 800 x 600, 8-bit colormap, non-interlaced
24-bit.png: PNG image data, 800 x 600, 8-bit/color RGB, non-interlaced
32-bit.png: PNG image data, 800 x 600, 8-bit/color RGBA, non-interlaced

As you can see 8-bit/color RGBA is actually what Paint.NET calls a 32-bit PNG, because it's 8 bits per color * (3 colors + 1 alpha channel). 8 * 4 = 32. A 24-bit PNG is the same, but without the alpha channel: 8 * 3 = 24.

If you want what Paint.NET calls a 24-bit PNG, you need to remove the alpha channel. As far as I can tell, GIMP always exports a PNG with an alpha channel if any of your layers has an alpha channel.

If you're only using 1 layer, then it's simple: Go to Layer > Transparency > Remove Alpha Channel and then export. You'll get a 24-bit PNG.

If you're using multiple layers and need transparency effects, then jthill pointed out that you can use Image > Flatten Image to remove the layers with transparency before exporting. You can then Undo to restore the layers.

You can also post-process the exported PNG to remove the alpha channel. You could load the exported image back into GIMP, which will make it 1 layer, remove the alpha channel from that layer, and export again. A better way is to use optipng, which will usually compress a PNG better than GIMP can in addition to removing a useless alpha channel.

Solution 2

NOTE: If you're looking for 16-bits per channel support then this answer applies to that. Otherwise if you're miss understanding 24-bit support (8-bit * 3 colors (RGB) = 24-bits, then see @cjm's answer as to how to understand how that works.


From the GIMP FAQ:

excerpt

When can we see 16-bit per channel support (or better)?

For some industries, especially photography, 24-bit colour depths (8 bits per channel) are a real barrier to entry. Once again, it's GEGL to the rescue. Work on integrating GEGL into GIMP began after 2.4 was released, and will span across several stable releases. This work will be completed in GIMP 3.0, which will have full support for high bit depths. If you need such support now and can't wait, cinepaint and Krita support 16 bits per channel now.

The current development branch, GIMP 2.9.x, supports higher bit depths than the 2.8 and older 8-Bit-per-component...

In case you're not familiar with GEGL:

excerpt

GEGL (Generic Graphics Library) is a graph based image processing framework.

GEGL provides infrastructure to do demand based cached non destructive image editing on larger than RAM buffers. Through babl it provides support for a wide range of color models and pixel storage formats for input and output.

Features

  • Floating point handling and processing and output of larger 8bit, 16bit integer and 32bit floating
  • ....
Share:
10,419

Related videos on Youtube

PMint
Author by

PMint

Updated on September 18, 2022

Comments

  • PMint
    PMint almost 2 years

    Is there a way to save an image as 24 bit png? I didn't manage with GIMP. Keep in mind this is pixel art so keeping the exact colors are important.

    I tried several things in GIMP, but it always said this:

    $ file Junction.png 
    Junction.png: PNG image data, 160 x 60, 8-bit/color RGBA, non-interlaced
    

    Instead of 24 bit.

    • cjm
      cjm over 10 years
      8-bit/color is a 24 bit PNG (3 colors * 8 bits). Did you mean a 48 bit PNG (16-bit/color)?
    • PMint
      PMint over 10 years
      In paint.NET you can choose to save your picture 8bit, 24bit or 32bit. As there is no pain.NET on Linux and Pinta doesn't have it, I asked for it.
    • jiggunjer
      jiggunjer over 8 years
      It seems @cjm is (mistakenly) assuming the number of bits refers only to the color channels. But in an X-bit image 'X' refers to the number of bits of all the channels--unless the word "color" is specifically added after the X.
    • cjm
      cjm over 8 years
      @jiggunjer, if you read my answer instead of just my comment, you'll see I'm aware of that.