Microsoft.Maui.Graphics
Microsoft.Maui.Graphics copied to clipboard
Wrong IImage height and width
Good morning,
we are trying to use this library as simple substitute of System.Drawing.Common on Linux.
We use it for a very simple task: retrieving images (in our case .png) height and width but the returned numbers haven no sense.
Our code:
[HttpGet("{imgName}/dimensions")]
public ActionResult<dynamic> GetImageDimensions(string imgName)
{
string imgFileName = Path.Combine(Directory.GetCurrentDirectory(), _configuration["ImagesPath"], imgName);
float height, width;
using (var stream = System.IO.File.OpenRead(imgFileName))
{
using IImage image = GraphicsPlatform.CurrentService.LoadImageFromStream(stream);
height = image.Height;
width = image.Width;
}
return new { Height = height, Width = width};
}
{
"height": 218765840,
"width": -1991225700
}
Here the image specs from Windows:

We cannot understand if it is a bug or a strange measure unit. We found no docs about this package.
Another info about the CurrentService instance if it helps

Give LoadImageFromStream the optional second parameter, to tell it the image type:
LoadImageFromStream(stream, ImageFormat.Png);
I'm guessing it didn't figure out that it was a png.
Nothings change specifying the ImageFormat also because .png is the default.
I'm having this error as well:


also get wrong width & size and if change image format to save(png->jpeg), get error: System.NotImplementedException: 'The method or operation is not implemented.'