Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Net Core Cross-platform Graphics processing Library ImageSharp how to analyze

Shulou Source: shulou.com Published: 2022-06-01 05:00:43 09月23日 Update

This article shows you. NET Core cross-platform graphics processing library ImageSharp how to analyze, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.

ImageSharp is a cross-platform graphics processing library that supports .NET Core, and ImageSharp is a cross-platform implementation of ImageProcessor. NET Core.

ImageSharp supports the following operations:

Resize, crop, flip, rotate, edge detection, etc.

Support for BMP,PNG,GIF,JPEG encoders.

EXIF reads and writes for JPEG.

Drawing is not supported yet, that is, operations such as CAPTCHA and watermarking are not supported.

GitHub: https://github.com/JimBobSquarePants/ImageSharp

The current version is 1.0.0-alpha7.

New project

Create a new .NET Core console application.

Add referenc

Since it is still an alpha version, it has not been placed in NuGet, it is https://www.myget.org/gallery/imagesharp on MyGet.

Add the ImageSharp source to the NuGet package source.

ImageSharp source address: https://www.myget.org/F/imagesharp

Then execute the command in the NuGet console:

Install-Package ImageSharp-Version 1.0.0-alpha7

Write code

First of all, we need a picture and place it in the root directory of the program. The command is lena.jpg.

The sample code is as follows:

Public static void Main (string [] args) {

/ / read EXIFusing (FileStream input = File.OpenRead ("lena.jpg")) {Image image = new Image (input); var exif = image.ExifProfile.Values; foreach (var item in exif) {Console.WriteLine (item.Tag+ ":" + item.Value) }} / / Zoom using (FileStream input = File.OpenRead ("lena.jpg")) using (FileStream output = File.OpenWrite ("lena2.jpg")) {Image image = new Image (input) Image.Resize (image.Width / 2, image.Height / 2) .Save (output);} / / crop using (FileStream input = File.OpenRead ("lena.jpg"))

Using (FileStream output = File.OpenWrite ("lena3.jpg")) {Image image = new Image (input); image.Crop (image.Width / 2, image.Height / 2) .Save (output);} / / rotate 180 °using (FileStream input = File.OpenRead ("lena.jpg"))

Using (FileStream output = File.OpenWrite ("lena4.jpg")) {Image image = new Image (input); image.Rotate (RotateType.Rotate180) .Save (output) } / / simply draw blank using (FileStream output = File.OpenWrite ("lena5.jpg")) {Image image = new Image (100200); Color [] colors = new Color [20000]; for (int I = 0; I < 20000) Colors +) {colors [I] = Color.White;} image.SetPixels (100,200, colors); image.Save (output);} Console.ReadKey ();}

Running the program will get the following figure in the root directory of the program

The above is how to analyze the .NET Core cross-platform graphics processing library ImageSharp. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Programs support graphics graphics processing processing analysis code content commands skills console root directory knowledge control concise concise pixel address size that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Shulou Technology Shulou Information Xiaomi