/// <summary> /// Read basic information about an image. /// </summary> /// <param name="fileName">The fully qualified name of the image file, or the relative image file name.</param> /// <param name="readSettings">The settings to use when reading the image.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(string fileName, MagickReadSettings readSettings) { using (MagickImage image = new MagickImage()) { image.Ping(fileName, readSettings); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="data">The span of bytes to read the information from.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(ReadOnlySpan <byte> data) { using (var image = new MagickImage()) { image.Ping(data); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="stream">The stream to read the image data from.</param> /// <param name="readSettings">The settings to use when reading the image.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(Stream stream, MagickReadSettings readSettings) { using (MagickImage image = new MagickImage()) { image.Ping(stream, readSettings); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="fileName">The fully qualified name of the image file, or the relative image file name.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(string fileName) { using (MagickImage image = new MagickImage()) { image.Ping(fileName); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="file">The file to read the image from.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(FileInfo file) { using (MagickImage image = new MagickImage()) { image.Ping(file); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="stream">The stream to read the image data from.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(Stream stream) { using (MagickImage image = new MagickImage()) { image.Ping(stream); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="data">The byte array to read the information from.</param> /// <param name="readSettings">The settings to use when reading the image.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(byte[] data, MagickReadSettings readSettings) { using (MagickImage image = new MagickImage()) { image.Ping(data, readSettings); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="data">The byte array to read the information from.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(byte[] data) { using (MagickImage image = new MagickImage()) { image.Ping(data); Initialize(image); } }
/// <summary> /// Read basic information about an image. /// </summary> /// <param name="data">The byte array to read the information from.</param> /// <param name="offset">The offset at which to begin reading data.</param> /// <param name="count">The maximum number of bytes to read.</param> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public void Read(byte[] data, int offset, int count) { using (var image = new MagickImage()) { image.Ping(data, offset, count); Initialize(image); } }
public void Test_Dimensions() { using (MagickImage image = new MagickImage()) { MagickReadSettings settings = new MagickReadSettings(); settings.Width = 100; image.Read(Files.Logos.MagickNETSVG, settings); Assert.AreEqual(100, image.Width); Assert.AreEqual(48, image.Height); settings.Width = null; settings.Height = 200; image.Read(Files.Logos.MagickNETSVG, settings); Assert.AreEqual(415, image.Width); Assert.AreEqual(200, image.Height); settings.Width = 300; settings.Height = 300; image.Read(Files.Logos.MagickNETSVG, settings); Assert.AreEqual(300, image.Width); Assert.AreEqual(144, image.Height); image.Ping(Files.Logos.MagickNETSVG, settings); Assert.AreEqual(300, image.Width); Assert.AreEqual(144, image.Height); using (FileStream fs = File.OpenRead(Files.Logos.MagickNETSVG)) { fs.Seek(55, SeekOrigin.Begin); ExceptionAssert.Throws<MagickMissingDelegateErrorException>(() => { new MagickImageInfo(fs, settings); }); fs.Seek(55, SeekOrigin.Begin); settings.Format = MagickFormat.Svg; MagickImageInfo info = new MagickImageInfo(fs, settings); Assert.AreEqual(300, info.Width); Assert.AreEqual(144, info.Height); } } }
public void Test_Ping() { using (MagickImage image = new MagickImage()) { image.Ping(Files.FujiFilmFinePixS1ProJPG); ExceptionAssert.Throws<InvalidOperationException>(delegate () { image.GetReadOnlyPixels(); }); ImageProfile profile = image.Get8BimProfile(); Assert.IsNotNull(profile); } }
public void Test_Ping() { MagickImage image = new MagickImage(); ExceptionAssert.Throws<ArgumentException>(delegate () { image.Ping(new byte[0]); }); ExceptionAssert.Throws<ArgumentNullException>(delegate () { image.Ping((byte[])null); }); ExceptionAssert.Throws<ArgumentNullException>(delegate () { image.Ping((Stream)null); }); ExceptionAssert.Throws<ArgumentNullException>(delegate () { image.Ping((string)null); }); ExceptionAssert.Throws<ArgumentException>(delegate () { image.Ping(Files.Missing); }); image.Ping(Files.FujiFilmFinePixS1ProJPG); Test_Ping(image); Assert.AreEqual(600, image.Width); Assert.AreEqual(400, image.Height); image.Ping(new FileInfo(Files.FujiFilmFinePixS1ProJPG)); Test_Ping(image); Assert.AreEqual(600, image.Width); Assert.AreEqual(400, image.Height); image.Ping(File.ReadAllBytes(Files.FujiFilmFinePixS1ProJPG)); Test_Ping(image); Assert.AreEqual(600, image.Width); Assert.AreEqual(400, image.Height); image.Read(Files.SnakewarePNG); Assert.AreEqual(286, image.Width); Assert.AreEqual(67, image.Height); using (PixelCollection pixels = image.GetPixels()) { Assert.AreEqual(38324, pixels.ToArray().Length); } image.Dispose(); }