图像水印 [英] Image watermark
本文介绍了图像水印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过C#使用Azure函数(较少服务器)对图像加水印?据我所知,Azure函数不支持System.Drawing库,因此我无法使用Graphic和Brushes类使用C#对图像进行水印处理.
Is there any way to watermark an image using Azure function (server less) with C#? As I got to know the System.Drawing library is unsupported by Azure function so I am unable to use Graphic and Brushes classes to watermark an image using C#.
推荐答案
您可以使用其他库,例如 Magick.NET .
我尝试了一个使用ImageSharp的简单功能,将图像转换为可以按预期工作的灰度.
I have tried a simple function using ImageSharp to convert images to greyscale which worked as expected.
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace funk_csharp
{
public static class ConvertToGrayscale
{
[FunctionName("ConvertToGrayscale")]
public static void Run(
[BlobTrigger("sample-images/{name}")] Stream image,
[Blob("sample-images-gray/{name}", FileAccess.Write)] Stream imageGrey,
string name,
ILogger log
)
{
Image<Rgba32> img = Image.Load(image);
img.Mutate(ctx => ctx.Grayscale());
img.SaveAsPng(imageGrey);
}
}
}
此处是用于水印的ImageSharp示例.
Here is a ImageSharp sample for watermarking.
这篇关于图像水印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文