0

我正在尝试将图像的所有白色背景(使用插件从 Html 生成)转换为透明,以便我可以将其用作图章

Using image As MagickImage = New MagickImage(filenamelocation)
                    image.Alpha(AlphaOption.Set)
                    image.ColorFuzz = New Percentage(40)
                    image.Settings.BackgroundColor = MagickColors.Transparent
                    image.Settings.FillColor = MagickColors.White
                    image.FloodFill(MagickColors.Transparent, 0, 0)   
                    image.Write(Path.Combine(Server.MapPath("~/Uploads/attachment/"), "stampimagename.png"))
                End Using

我的 png 图像是这样的

我正在使用 ImageMagick nuget 包做同样的事情,需要将所有白色转换为透明只有蓝色项目显示仍然存在,有人可以建议我做错了什么

4

1 回答 1

0

我不认为你应该将背景声明为透明然后填充白色(不太确定这意味着什么......)

据我了解,通过阅读执行此操作的命令行操作(并转换为 VB;似乎大多数命令行和 VB 相似),您只需要加载图像,声明白色是透明色,使用可能是一些模糊因素,然后将其保存为支持透明度的格式:

Using image As MagickImage = New MagickImage(filenamelocation)

    image.ColorFuzz = new Percentage(10) 'declare a lower fuzz factor
    img.Transparent(MagickColors.White) 'declare that the transparency should apply to anything that is white 
    img.Write("image.png") 'save as a format that support transparency. jpg does not

End Using
于 2020-06-24T15:23:29.157 回答