Is there an issue with transparent png using WhitespaceTrimmer plugin

自闭症网瘾萝莉.ら 提交于 2020-01-06 13:53:41

问题


When I try to trim an image that has a transparent background using the WhitespaceTrimmer plugin i end up with a 3x3 image with nothing in it.

However when I save my source image in paint and the transparent background becomes a solid white background the WhitespaceTrimmer works great.

Am I doing anything wrong which would make the trimmer not function on my original image or is this some sort of bug or unsupported feature?

Original source:

Output of original source (there is a 3x3 image there somewhere):

Original image saved with a white background (using MS Paint):

Output of white background image:

Test Code used to output image through asp.net

    Response.Clear()

    Response.AppendHeader("Content-Disposition", "attachment; filename=testSigOutput.png")
    Response.ContentType = diFunctions.getContentType("png")

    ImageBuilder.Current.Build("C:\Solutions\TestImages\testSig.png", Response.OutputStream, New ResizeSettings("trim.threshold=80&trim.percentpadding=0.5"))
    Response.End()

Edit: I did some additional testing, I have come to the conclusion that when it converts the image to grayscale it is treating transparent pixels as black.

Regardless of what color I set the transparent background pixels to it will not work.

However if I change the pen color or make the background slightly visible (0.01 alpha) it works fine.

So the answer is I have a work around but is this working as intended?


回答1:


WhitespaceTrimmer converts images to grayscale so that an energy filter can be applied. It's likely that your image turns into a black square when converted to grayscale. To test this, try making the figure in your image a different color (but still against a transparent background).

Another possibility is that the transparent pixels in the image are of the same color, and thus the outline only exists in the alpha channel - which is not multiplied against the other channels.



来源:https://stackoverflow.com/questions/26762284/is-there-an-issue-with-transparent-png-using-whitespacetrimmer-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!