Imagesharp is a support for the. NET core cross-platform graphics processing library, Imagesharp is Imageprocessor's. NET core cross-platform implementation.
IMAGESHARP supports the following operations:
resizing, cropping, flipping, rotation, edge detection, etc.
Supports Bmp,png,gif,jpeg encoders.
EXIF reads and writes for JPEG.
Temporarily does not support drawing, that is, can not support verification code and watermark and other operations.
Github:https://github.com/jimbobsquarepants/imagesharp
The current version is 1.0.0-alpha7.
New Project
Create a new. NET Core Console Application.
Add Reference
Because it is still alpha, it is not placed in NuGet and 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
Writing code
First we need a diagram to place it at the root of the program command as Lena.jpg.
The sample code is as follows:
Public Static voidMain (string[] args) { //Read EXIF using(FileStream input = File.openread ("lena.jpg") {image Image=NewImage (input); varEXIF =image. Exifprofile.values; foreach(varIteminchEXIF) {Console.WriteLine (item. Tag+":"+item. Value); } } //Zoom using(FileStream input = File.openread ("lena.jpg")) using(FileStream output = File.openwrite ("lena2.jpg") {image Image=NewImage (input); Image. Resize (image. Width/2, image. Height/2) . Save (output); } //cropping using(FileStream input = File.openread ("lena.jpg")) using(FileStream output = File.openwrite ("lena3.jpg") {image Image=NewImage (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=NewImage (input); Image. Rotate (rotatetype.rotate180). Save (output); } //set the pixel point way to simply draw a blank using(FileStream output = File.openwrite ("lena5.jpg") {image Image=NewImage (1xx, 2xx); color[] Colors=Newcolor[20000]; for(inti =0; I <20000; i++) {Colors[i]=Color.White; } image. SetPixels ( -, $, colors); Image. Save (output); } console.readkey (); }
Run the program in the program root directory to get the following figure
The above is the simple use of imagesharp, and more can be seen on the official GitHub.
If you think this article is helpful to you, please click " recommend ", thank you.
Imagesharp. NET Core cross-platform graphics processing library