I recreated the issue in a minimal form:
MAIN:
public class ImageIOMain extends Application {
@Override
public void start(Stage stage) throws Exception{
Scene scene = new Scene(new StackPane(), 800.0, 600.0);
stage.setScene(scene);
stage.show();
WritableImage img = scene.snapshot(null);
//Image file created on desktop
ImageIO.write(SwingFXUtils.fromFXImage(img, null), "png", new File("D:\\Desktop\\test.png"));
//Image file NOT created on desktop
ImageIO.write(SwingFXUtils.fromFXImage(img, null), "jpeg", new File("D:\\Desktop\\test.jpeg"));
}
public static void main(String[] args) {
launch(args);
}
}
Important: I'm using JavaFX 12.
If I export an image as png
the image shows up on my desktop. If the file format is for example jpeg
then the image is not created.
In the past when I used JavaFX 8 saving as jpeg
using the above code caused the image to became pink toned. Now in version 12 nothing happens.
So how can I create an image which format is not png
but something else like jpeg
?
I also checked ImageIO supported formats which returns these:
JPG, jpg, tiff, bmp, BMP, gif, GIF, WBMP, png, PNG, JPEG, tif, TIF, TIFF, wbmp, jpeg