How to check valid Image using stream?

I’m trying to validate image file using below method:

     if (System.IO.File.Exists("D:\\architecture.png"))
                    {
                        using (var streams = new FileStream("D:\\architecture.png",FileMode.Open))
                        {
                            bIsValid = Aspose.Imaging.Image.CanLoad(streams);
                        }
                    }

CanLoad method throws error:
System.ArgumentOutOfRangeException: Non-negative number required. Parameter name: count

How to check valid Image file using stream?

PS: I referred below links but solution found.

https://reference.aspose.com/net/imaging/aspose.imaging/image/methods/canload

architecture.png (91.8 KB)

@cyginfo,

I have observed the issue shared by you and request you to please provide the source file reproducing the issue. Please also try setting the stream position to 0 as well before checking.

I’ve attached and updated my query. Although, I’m facing same issue in image file format(.jpg,.png,.bmp)

@cyginfo,

I have worked with your file using Aspose.Imaging for .NET 19.12 and there is no issue while verifying the stream using Aspose.Imaging. Can you please try using shared project.

TestImaging.zip (186.0 KB)

Thank you. But we are using Aspose.Imaging 19.1 version.

Is there any way to validate Image stream without having to update version?

@cyginfo,

I like to share that we can only log issue if it is getting reproduced using latest version. In your case, I suggest you to please try using latest Aspose.Imaging for .NET 19.12 on your end.