ImageResizer水印未显示

时间:2017-03-28 14:18:42

标签: imageresizer

我有一个Azure功能,它试图使用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();
}

关于为什么没有应用水印的任何想法?

1 个答案:

答案 0 :(得分:0)

Watermark插件需要虚拟路径,如&#39;〜/ azure / blobimage.jpg&#39;。它不接受可能位于应用程序根目录或已装入文件夹之外的物理路径。