Java Save Images [duplicate]
This question already has an answer here:
ImageIO.write not working?
1 answer
I have written a program that generates images for me.
That works so far, save on the save.
In the method I want to save I have a WritabelImage
I make a BuffertImage
with the SwingFXUtils.fromFXImage ()
. In the debugger of Intellij I can also look at it and it is actually there.
Then I have the output path created as URI and pass this to a Fil
object.
With ImageIO.write ()
I would like to combine and save both.
And that does not work.
The path exits.
I tried it with the direct URI and also with the uri.getPath ()
I just do not know how to continue.
Can you please help me with that?
try {
String path;
URI uri;
uri = this.getClass().getResource("").toURI();
path = uri.toString().replace("foo/bar/foobar/generate/", "generate/out/" + name + ".png");
uri = URI.create(path);
File outputFile = new File(uri.getPath());
BufferedImage bImage = SwingFXUtils.fromFXImage(writableImage, null);
System.out.println("Saved");
ImageIO.write(bImage, ".png", outputFile);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (URISyntaxException e) {
e.printStackTrace();
}
java swing javafx java-8
marked as duplicate by fabian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 12:24
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
ImageIO.write not working?
1 answer
I have written a program that generates images for me.
That works so far, save on the save.
In the method I want to save I have a WritabelImage
I make a BuffertImage
with the SwingFXUtils.fromFXImage ()
. In the debugger of Intellij I can also look at it and it is actually there.
Then I have the output path created as URI and pass this to a Fil
object.
With ImageIO.write ()
I would like to combine and save both.
And that does not work.
The path exits.
I tried it with the direct URI and also with the uri.getPath ()
I just do not know how to continue.
Can you please help me with that?
try {
String path;
URI uri;
uri = this.getClass().getResource("").toURI();
path = uri.toString().replace("foo/bar/foobar/generate/", "generate/out/" + name + ".png");
uri = URI.create(path);
File outputFile = new File(uri.getPath());
BufferedImage bImage = SwingFXUtils.fromFXImage(writableImage, null);
System.out.println("Saved");
ImageIO.write(bImage, ".png", outputFile);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (URISyntaxException e) {
e.printStackTrace();
}
java swing javafx java-8
marked as duplicate by fabian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 12:24
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
ImageIO.write not working?
1 answer
I have written a program that generates images for me.
That works so far, save on the save.
In the method I want to save I have a WritabelImage
I make a BuffertImage
with the SwingFXUtils.fromFXImage ()
. In the debugger of Intellij I can also look at it and it is actually there.
Then I have the output path created as URI and pass this to a Fil
object.
With ImageIO.write ()
I would like to combine and save both.
And that does not work.
The path exits.
I tried it with the direct URI and also with the uri.getPath ()
I just do not know how to continue.
Can you please help me with that?
try {
String path;
URI uri;
uri = this.getClass().getResource("").toURI();
path = uri.toString().replace("foo/bar/foobar/generate/", "generate/out/" + name + ".png");
uri = URI.create(path);
File outputFile = new File(uri.getPath());
BufferedImage bImage = SwingFXUtils.fromFXImage(writableImage, null);
System.out.println("Saved");
ImageIO.write(bImage, ".png", outputFile);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (URISyntaxException e) {
e.printStackTrace();
}
java swing javafx java-8
This question already has an answer here:
ImageIO.write not working?
1 answer
I have written a program that generates images for me.
That works so far, save on the save.
In the method I want to save I have a WritabelImage
I make a BuffertImage
with the SwingFXUtils.fromFXImage ()
. In the debugger of Intellij I can also look at it and it is actually there.
Then I have the output path created as URI and pass this to a Fil
object.
With ImageIO.write ()
I would like to combine and save both.
And that does not work.
The path exits.
I tried it with the direct URI and also with the uri.getPath ()
I just do not know how to continue.
Can you please help me with that?
try {
String path;
URI uri;
uri = this.getClass().getResource("").toURI();
path = uri.toString().replace("foo/bar/foobar/generate/", "generate/out/" + name + ".png");
uri = URI.create(path);
File outputFile = new File(uri.getPath());
BufferedImage bImage = SwingFXUtils.fromFXImage(writableImage, null);
System.out.println("Saved");
ImageIO.write(bImage, ".png", outputFile);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (URISyntaxException e) {
e.printStackTrace();
}
This question already has an answer here:
ImageIO.write not working?
1 answer
java swing javafx java-8
java swing javafx java-8
asked Nov 24 '18 at 11:47
AdrianAdrian
509
509
marked as duplicate by fabian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 12:24
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by fabian
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 24 '18 at 12:24
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The format name parameter is not supposed to include a dot. Try simply "png"
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The format name parameter is not supposed to include a dot. Try simply "png"
add a comment |
The format name parameter is not supposed to include a dot. Try simply "png"
add a comment |
The format name parameter is not supposed to include a dot. Try simply "png"
The format name parameter is not supposed to include a dot. Try simply "png"
answered Nov 24 '18 at 11:52
OhleCOhleC
1,829720
1,829720
add a comment |
add a comment |