Menu

FreeImage returns null for "FreeImage_ConvertToGreyscale on a png file

Help
2021-09-05
2021-10-05
  • Karel Varel

    Karel Varel - 2021-09-05

    Hello.
    I am trying to convert this file to grayscale using FreeImage (.NET wrapper).
    I have successfully converted approximately 1100 similar images to grayscale (it's really fast) using FreeImage.
    Call to FreeImage_ConvertToGreyscale function results in null output value.
    I can see that there is something strange about the color depth detected by FreeImage (taken from sample 04 of .NET wrapper).
    info

    Image is added as attachment.

    Info from http://exif.regex.info/exif.cgi added as attachment (.zip).

    What do you think is wrong about this image?
    Thank you

     

    Last edit: Karel Varel 2021-09-05
  • Mihail Naydenov

    Mihail Naydenov - 2021-09-06

    Hi, looking at the code, FreeImage_ConvertToGreyscale does not work with FIT_RGB16 images.
    If you don't care about 16bit color, convert first to FIT_BITMAP, then run ConvertToGrayscale.
    If you do care about 16bit, I think you can simply convert to FIT_UINT16

     
  • Johnny Petersen

    Johnny Petersen - 2021-10-05

    Per the uploaded PNG file, the BitDepth is 8 and the ColorType 2, hence the Image Type: FIT-RGB16 that you got seems to be a wrong one.

     
  • Mihail Naydenov

    Mihail Naydenov - 2021-10-05

    @Johnny Petersen The original is in the zip 5d630284307d0a64696d10b26d13f6af.png

     
  • Johnny Petersen

    Johnny Petersen - 2021-10-05

    @Mihail Naydenov Thank you, I got it. The original inside the zip is with BitDepth = 16 and ColorType = 2. Without ICC and not interlaced.

     

Log in to post a comment.