Skip to content

Commit

Permalink
Adding failing test to check if the fix for PDF is working
Browse files Browse the repository at this point in the history
  • Loading branch information
glenrobson committed Aug 14, 2024
1 parent dc7947a commit 2bf4e4d
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,28 @@ public void testWriteWithBufferedImage() throws Exception {
}
}

/**
* Note the TurboJPEGImageWriter.write method is used in the PDFbox processor
*/
@Test
public void testWriteWithBufferedImageYZero() throws Exception {
Path path = TestUtil.getImage("jpg");
BufferedImage image = ImageIO.read(path.toFile());

image = image.getSubimage(0, 10, 10,10);

try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
instance.write(image, os);
ImageInputStream is = ImageIO.createImageInputStream(new ByteArrayInputStream(os.toByteArray()));
image = ImageIO.read(is); // also closes the stream
Color color = new Color(image.getRGB(0,0));
assertEquals(116, color.getRed(), "Expected a particular color pixel but it wasn't found. Potentially the TurboJPEGImageWriter is returning the wrong image. Red value");
assertEquals(151, color.getGreen(), "Expected a particular color pixel but it wasn't found. Potentially the TurboJPEGImageWriter is returning the wrong image. Green value");
assertEquals(97, color.getBlue(), "Expected a particular color pixel but it wasn't found. Potentially the TurboJPEGImageWriter is returning the wrong image. Blue value");
// ImageIO.write(image, "jpg", new java.io.File("/tmp/test.jpg"));
}
}

@Test
public void testWriteWithGrayBufferedImage() throws Exception {
BufferedImage image = new BufferedImage(50, 50,
Expand Down

0 comments on commit 2bf4e4d

Please sign in to comment.