问题
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