I have the following java method, which successfully creates the png file:
TakesScreenshot scrShot = ((TakesScreenshot) webdriver);
File SrcFile = scrShot.getScreenshotAs(OutputType.FILE);
File DestFile = new File(fileWithPath + featureFileName + ".png");
// BufferedImage img = ImageIO.read(SrcFile);
// ImageIO.write(img, "jpg", new File(fileWithPath + featureFileName + ".jpg"));
FileUtils.copyFile(SrcFile, DestFile);
I'm trying to convert the image to jpg using the 2 commented lines, but jpg output file is not being produced. No error. No file. I can't figure out why. Thanks in advance for any help.
You are likely using OpenJDK that is having number of issues with JPG encoding, especially when you convert from png.
So that your workaround would be to convert image
BufferedImageto anotherBufferedImageand then save it like: