PngLoadOptionsStrictMode Property
Gets or sets a value indicating whether [strict mode].

Namespace: Aspose.Imaging.ImageLoadOptions
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 20.05
public bool StrictMode { get; set; }

Property Value

Type: Boolean
true if [strict mode]; otherwise, false.
The following example shows how to read PNG file in a strict mode. The strict mode allows to find potential problems in PNG images, e.g. unrecognized data blocks, unexpected end of file. Such files still can be opened in default (non-strict) mode by Aspose.Imaging and by common viewers as well. However any attempts to open them in the strict mode cause a corresponding exception.

string dir = "c:\\aspose.imaging\\issues\\net\\3635\\testdata\\3565";
string inputFileName = System.IO.Path.Combine(dir, "FC5F1998104EB92469CB14070628073616BB28F9.png");
string outputFileName = inputFileName + ".png";

// Default mode (non-strict) - successul reading.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFileName))
    image.Save(outputFileName, new Aspose.Imaging.ImageOptions.PngOptions());

// Strict mode - ImageLoadException : Unexpected end of file.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFileName, new Aspose.Imaging.ImageLoadOptions.PngLoadOptions() { StrictMode = true }))
    image.Save(outputFileName, new Aspose.Imaging.ImageOptions.PngOptions());
See Also