@Test
    void testWriteImageRaw_happyCase() throws ImagingException, ImagingException, IOException {
        final BufferedImage srcImage = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);

        final byte[] dstBytes = Imaging.writeImageToBytes(srcImage, ImageFormats.PNM);
        final BufferedImage dstImage = Imaging.getBufferedImage(dstBytes);

        assertEquals(srcImage.getWidth(), dstImage.getWidth());
        assertEquals(srcImage.getHeight(), dstImage.getHeight());

        final DataBufferInt srcData = (DataBufferInt) srcImage.getRaster().getDataBuffer();
        final DataBufferInt dstData = (DataBufferInt) dstImage.getRaster().getDataBuffer();

        for (int bank = 0; bank < srcData.getNumBanks(); bank++) {
            final int[] actual = srcData.getData(bank);
            final int[] expected = dstData.getData(bank);

            assertArrayEquals(actual, expected);
        }
    }
If an invalid width is specified, should throw {@link ImagingException} rather than {@link NumberFormatException}.
src/test/java/org/apache/commons/imaging/formats/pnm/PnmImageParserTest.java