ImageResizer 水印未出现
ImageResizer Watermark not appearing
我有一个 Azure Function,它正在尝试使用 ImageResizer 3.4.3 版向现有图像添加水印。该函数执行无误,但未应用水印。这是代码,紧随 here:
private static void ApplyWatermark(Stream inputStream, string blobName)
{
var imageConfiguration = Config.Current;
var plugin = imageConfiguration.Plugins.Get<WatermarkPlugin>();
if (plugin == null)
{
plugin = new WatermarkPlugin();
plugin.Install(imageConfiguration);
}
plugin = imageConfiguration.Plugins.Get<WatermarkPlugin>();
var imageLayer = new ImageLayer(imageConfiguration)
{
Path = HostingEnvironment.MapPath(_configuration.Get<string>("BadgeUrl")),
Align = ContentAlignment.MiddleCenter
};
plugin.NamedWatermarks["badge"] = new Layer[]
{
imageLayer
};
inputStream.Position = 0;
var outputStream = new MemoryStream();
imageConfiguration.CurrentImageBuilder.Build(inputStream, outputStream,
new ResizeSettings("watermark=badge"));
outputStream.Position = 0;
_blobStorageRepository.AddorUpdateAsync(_configuration.BlobStorageContainer,
blobName, outputStream).Wait();
}
关于为什么不应用水印有什么想法吗?
Watermark 插件需要类似“~/azure/blobimage.jpg”的虚拟路径。它不接受可能位于应用程序根目录或已安装文件夹之外的物理路径。
我有一个 Azure Function,它正在尝试使用 ImageResizer 3.4.3 版向现有图像添加水印。该函数执行无误,但未应用水印。这是代码,紧随 here:
private static void ApplyWatermark(Stream inputStream, string blobName)
{
var imageConfiguration = Config.Current;
var plugin = imageConfiguration.Plugins.Get<WatermarkPlugin>();
if (plugin == null)
{
plugin = new WatermarkPlugin();
plugin.Install(imageConfiguration);
}
plugin = imageConfiguration.Plugins.Get<WatermarkPlugin>();
var imageLayer = new ImageLayer(imageConfiguration)
{
Path = HostingEnvironment.MapPath(_configuration.Get<string>("BadgeUrl")),
Align = ContentAlignment.MiddleCenter
};
plugin.NamedWatermarks["badge"] = new Layer[]
{
imageLayer
};
inputStream.Position = 0;
var outputStream = new MemoryStream();
imageConfiguration.CurrentImageBuilder.Build(inputStream, outputStream,
new ResizeSettings("watermark=badge"));
outputStream.Position = 0;
_blobStorageRepository.AddorUpdateAsync(_configuration.BlobStorageContainer,
blobName, outputStream).Wait();
}
关于为什么不应用水印有什么想法吗?
Watermark 插件需要类似“~/azure/blobimage.jpg”的虚拟路径。它不接受可能位于应用程序根目录或已安装文件夹之外的物理路径。