Trim an image to a percentage of its size (webGL and webGPU) ported from a shader by user Somebody.
Really late reply, originally this was just a port of a c2 shader from user Somebody. But now I have rewritten the shader with a fixes for both of these issues.