CloudYxt.Imager
3.0.1
dotnet add package CloudYxt.Imager --version 3.0.1
NuGet\Install-Package CloudYxt.Imager -Version 3.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CloudYxt.Imager" Version="3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CloudYxt.Imager --version 3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CloudYxt.Imager, 3.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CloudYxt.Imager as a Cake Addin
#addin nuget:?package=CloudYxt.Imager&version=3.0.1
// Install CloudYxt.Imager as a Cake Tool
#tool nuget:?package=CloudYxt.Imager&version=3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
云享通.Net Core图形图像快捷操作库
从BASE64读取图片
var img = ImageBase64.FromString("data:image/png;base64,iVBORw0KGgoAAAA......");
获取图片格式名称
var format = img.RawFormatName();
Console.WriteLine(format);
重绘图片为静态网页RGB格式
var staticPic = img.ToRGBDraw();
清除图片的EXIF信息
img.ClearExif();
调整大小(可按比例)
/// <param name="w">重绘的宽度值,为0则不处理</param>
/// <param name="h">重绘的高度值,为0则不处理</param>
/// <param name="x">重绘的x定位位置,为0则不处理</param>
/// <param name="y">重绘的y定位位置,为0则不处理</param>
img.ToResize(w, h, x, y);
加水印(可按比例)
/// <param name="img_water">水印图</param>
/// <param name="x">水印距离原始图的x坐标位置,若为负数则从右向左计算</param>
/// <param name="y">水印距离原始图的y坐标位置,若为负数则从下向上计算</param>
/// <param name="mult">相对原始图的图片倍数,以宽计算,默认为0.28</param>
img.ToWater(img_water, x, y, mult);
将图片保存为字节数组
//同步方法
img.SaveToByte(new JpegEncoder()
{
Quality = 100,
SkipMetadata = true,
});
//异步方法
await img.SaveToByteAsync(new JpegEncoder()
{
Quality = 100,
SkipMetadata = true,
});
生成二维码
//创建QR生成器
var qr = QrCode.EncodeText(url, QrCode.Ecc.Medium);
//生成二维码字节数组
var data = qr.ToPng();
//ASP.NET输出到Response
Response.ContentType = "image/png";
await Response.Body.WriteAsync(data, 0, data.Length);
生成二维码的可选方法
/// <summary>
/// 生成QR为PNG格式的byte[]
/// </summary>
/// <param name="qrCode"></param>
/// <param name="scale">每个模块的宽度和高度,以像素为单位,默认为10</param>
/// <param name="border">添加到每个四边的边框模块的数量,默认为4</param>
/// <param name="foreground">二维码颜色</param>
/// <param name="background">背景色</param>
/// <param name="logoImage">二维码中间LOGO</param>
/// <returns></returns>
public static byte[] ToPng(this QrCode qrCode, int scale, int border, Color foreground, Color background, Image logoImage = null)
/// <summary>
/// 生成QR为PNG格式的byte[]
/// </summary>
/// <param name="qrCode"></param>
/// <param name="scale">每个模块的宽度和高度,以像素为单位,默认为10</param>
/// <param name="border">添加到每个四边的边框模块的数量,默认为4</param>
/// <param name="foreground">二维码颜色</param>
/// <param name="background">背景色</param>
/// <param name="logoUrl">二维码中间LOGO的URL地址</param>
/// <returns></returns>
public static async Task<byte[]> ToPngAsync(this QrCode qrCode, int scale, int border, Color foreground, Color background, string logoUrl)
/// <summary>
/// 生成QR为PNG格式的文件
/// </summary>
/// <param name="qrCode"></param>
/// <param name="filename">文件路径</param>
/// <param name="scale">每个模块的宽度和高度,以像素为单位,默认为10</param>
/// <param name="border">添加到每个四边的边框模块的数量,默认为4</param>
/// <param name="foreground">二维码颜色</param>
/// <param name="background">背景色</param>
/// <param name="logoImage">二维码中间LOGO</param>
public static void SaveAsPng(this QrCode qrCode, string filename, int scale, int border, Color foreground, Color background, Image logoImage = null)
/// <summary>
/// 生成QR为PNG格式的文件
/// </summary>
/// <param name="qrCode"></param>
/// <param name="filename">文件路径</param>
/// <param name="scale">每个模块的宽度和高度,以像素为单位,默认为10</param>
/// <param name="border">添加到每个四边的边框模块的数量,默认为4</param>
/// <param name="foreground">二维码颜色</param>
/// <param name="background">背景色</param>
/// <param name="logoUrl">二维码中间LOGO的URL地址</param>
public static async Task SaveAsPngAsync(this QrCode qrCode, string filename, int scale, int border, Color foreground, Color background, string logoUrl = null)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Net.Codecrete.QrCodeGenerator (>= 2.0.4)
- SixLabors.ImageSharp.Drawing (>= 2.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
云享通.Net Core图形图像快捷操作库。
3.0.1:
优化ToRGBDraw,增加可选自定义图像分辨率
3.0.0:
增加基于Net.Codecrete.QrCodeGenerator的二维码生成方法,并支持二维码中间LOGO
2.0.0:
调整依赖包为SixLabors.ImageSharp,以支持跨平台图像处理,调整方法名以适配新的依赖包
1.0.0:
图片调整大小ResizeTo、图片打水印WaterTo
快捷格式存储ToJPGByte、ToPNGByte
从字节数组创建图片FromByte、从BASE64文本创建图片FromBase64