public static byte[] autoCrop(final byte[] data, final int fuzziness) throws IOException {
        final BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
        final BufferedImage cropped = autoCrop(image, fuzziness);
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImageIO.write(cropped, "png", out);
        return out.toByteArray();
    }
Crops an image based on the value of the top left pixel.

@param data
           The image data.
@param fuzziness
           The fuzziness allowed for minor deviations (~5 is
           recommended).
@return The new image data, cropped.
@throws IOException
            If the image could not be read.
src/main/java/com/kodedu/other/AutoCrop.java