tool - Nuget Pakage Manager - Console: PM Install-Package Imageprocessor
tool - Nuget Pakage Manager - Console: PM Install-Package Imageprocessor
NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using ImageProcessor;
using ImageProcessor.Imaging.Formats;
using System.Drawing;
namespace ASPNETImageProcessing
{
class Program
{
static void Main(string[] args)
{
//byte[] photoBytes = File.ReadAllBytes("Apollo11_Launch7.png");
byte[] photoBytes = File.ReadAllBytes("YellowCar.png");
// Format is automatically detected though can be changed.
ISupportedImageFormat format = new JpegFormat { Quality = 70 };
Size size = new Size(300, 0);
using (MemoryStream inStream = new MemoryStream(photoBytes))
{
using (MemoryStream outStream = new MemoryStream())
{
// Initialize the ImageFactory using the overload to preserve EXIF
metadata.
using (ImageFactory imageFactory = new ImageFactory(preserveExifData:
true))
{
// Load, resize, set the format and quality and save an image.
imageFactory.Load(inStream)
.Rotate(90)
.Resize(size)
.Format(format)
.Save(outStream);
}
// Do something with the stream.
using (FileStream file = new FileStream "outfile1.jpg",
FileMode.Create, FileAccess.Write))
{
outStream.WriteTo(file);
}
}
}
}