Bug 380970 - Wrong bit depth per channel reported, no export option to fix
Summary: Wrong bit depth per channel reported, no export option to fix
Status: RESOLVED WAITINGFORINFO
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 3.1.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-08 13:02 UTC by Brennan Kinney
Modified: 2017-06-09 10:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
.kra file (435.05 KB, application/octet-stream)
2017-06-08 13:31 UTC, Brennan Kinney
Details
.png 1-bit per channel (550 bytes, image/png)
2017-06-08 13:31 UTC, Brennan Kinney
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brennan Kinney 2017-06-08 13:02:23 UTC
Image -> Properties, Depth: 8-bit integer/channel

The image consists of 3 bands of solid R, G and B. due to the 0/255 values when I export to a format such as PNG, optimization appears to happen where Krita knows it could use 1-bit channels instead to represent the image. There is no option listed in the export dialog to prevent this.

While I'd like the image to retain the 0 and 255 channel values, this optimization prevents it being able to work with FreeImage(which a program I am trying to use the image with relies on) as it does not support the bit depth. Can the ability to prevent this during export be made available?

ImageMagick's `identify -verbose /path/to/image.png` is what helped me realize Krita was providing false information on bit depth of the image(probably because it could be edited as 8-bit in Krita and thus wasn't locked to 1-bit per channel like the stored format?).

identify output snippet:

 Depth: 8/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
    alpha: 1-bit
......
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 6
    png:IHDR.color_type: 6 (RGBA)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 9, 9
Comment 1 Halla Rempt 2017-06-08 13:16:55 UTC
Krita cannot work with indexed images nternally. There is an option to save png images as indexed, if possible. Please attach your original .kra file and the .png file your talking about to the bug report so I can check what's up.
Comment 2 Brennan Kinney 2017-06-08 13:31:01 UTC
Created attachment 105987 [details]
.kra file
Comment 3 Brennan Kinney 2017-06-08 13:31:39 UTC
Created attachment 105988 [details]
.png 1-bit per channel
Comment 4 Brennan Kinney 2017-06-08 13:32:44 UTC
(In reply to Boudewijn Rempt from comment #1)
> There is an option to save png images as indexed

I've seen that option and I had it unchecked.
Comment 5 Halla Rempt 2017-06-09 09:40:44 UTC
I think that it's libpng that does that automatically... Or maybe the standard forces this.

I converted the file to psd and saved the image with gimp and photoshop and identify gives exactly the same results:

Image: rgb_gimp.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 9x9+0+0
  Resolution: 37.4x37.4
  Print size: 0.240642x0.240642
  Units: PixelsPerCentimeter
  Type: Palette
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889

  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 9x9+0+0
  Resolution: 37.4x37.4
  Print size: 0.240642x0.240642
  Units: PixelsPerCentimeter
  Type: Palette
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
  Colors: 4


Heck, identify gives the same results on the psd file:

Image: rgb.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: DirectClass
  Geometry: 9x9+0+0
  Resolution: 95x95
  Print size: 0.0947368x0.0947368
  Units: PixelsPerInch
  Type: Palette
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8/1-bit
  Channel depth:
    red: 1-bit
    green: 1-bit
    blue: 1-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 103.889 (0.407407)
      standard deviation: 125.295 (0.491352)
      kurtosis: -1.85795
      skewness: 0.376889


So I'm not sure whether your analysis is correct. 

Btw, I know freeimage (http://freeimage.sourceforge.net/) only because it's a source of bugs where it's used in deepin's qimageio plugins. Or did you mean a different freeimage? How are you using freeimage with these png's?
Comment 6 Brennan Kinney 2017-06-09 09:53:30 UTC
> How are you using freeimage with these png's?

A library called ArrayFire that allows you to load images onto the GPU. I wanted to work with the values of 0 and 255 but it threw an error about FreeImage not being happy with the bitdepth.

I wasn't aware that was an issue with other popular image programs as well or due to a standard. In that case I guess this isn't a bug for Krita. The outcome of the export being optimized like that was just unexpected.
Comment 7 Halla Rempt 2017-06-09 09:58:56 UTC
Maybe use one of the formats that really are just the channel values concatenated?
Comment 8 Brennan Kinney 2017-06-09 10:08:05 UTC
It's not an issue for me with the library anymore as it was only for understanding how the data was presented via the API ArrayFire has. I had used jpg prior with max quality settings and from memory some 0 became 1 and some 255 became 254, which I guess is expected of a lossy format.

Thanks for clarifying everything :)