Troubleshoot Image Loading on Linux
C# .NET API on Linux is very sensitive to the image data format and structure. Sometimes recognition results may vary when loading the same image from different containers like PNG, TIFF or BMP.
Known limitations:
- Old versions of libgdiplus can crash when loading TIFF image files.
- System.Drawing.Bitmap object created by loading BMP format image file may have 0x0 resolution. Use the .NET Bitmap.SetResolution API to fix the DPI property after the loading.
- BMP format version 3 is recommended for loading an image. BMP format version 2 and 4 could load incorrectly causing recognition to fail.
- PNG files could have issues when loading due to the incorrect 96x96 or 72x72 resolution. Use the .NET Bitmap.SetResolution API to fix the DPI property after the loading.
Note that System.Drawing.Bitmap is not supported by Microsoft on Linux starting with .NET 6.0. We recommend you use the following to make it feasible to load images on any .NET version:
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>