internal static Image OnLoaded(Image image, ImageMetadata metadata, IList <Color> palette) { // try to fix invalid image resolution FixResolution(); // apply orientation ApplyOrientation(); // determine whether bitmap should be inverted bool invert = false; if (image.BitsPerPixel <= 8 && palette != null) { // convert color palette if (!BitmapExtensions.IsGrayScalePalette(image.BitsPerPixel, palette, out bool invertedPalette)) { return(image.ApplyPalette(palette)); } invert = invertedPalette; // remove palette metadata?.RemovePropertyItems(x => x.Id == (int)TIFFField.PhotometricInterpretation || x.Id == (int)TIFFField.ColorMap); } else { invert |= ApplyPhotometricInterpretation(); } if (invert) { image.Not(image); } return(image); // private methods void FixResolution() { (float w, float h)[] standardResolutions = new (float, float)[]