Java Save Images [duplicate]












1
















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();
}









share|improve this question













marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

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.























    1
















    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();
    }









    share|improve this question













    marked as duplicate by fabian java
    Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

    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.





















      1












      1








      1









      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();
      }









      share|improve this question















      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 11:47









      AdrianAdrian

      509




      509




      marked as duplicate by fabian java
      Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

      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 java
      Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

      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.


























          1 Answer
          1






          active

          oldest

          votes


















          2














          The format name parameter is not supposed to include a dot. Try simply "png"






          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            The format name parameter is not supposed to include a dot. Try simply "png"






            share|improve this answer




























              2














              The format name parameter is not supposed to include a dot. Try simply "png"






              share|improve this answer


























                2












                2








                2







                The format name parameter is not supposed to include a dot. Try simply "png"






                share|improve this answer













                The format name parameter is not supposed to include a dot. Try simply "png"







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 24 '18 at 11:52









                OhleCOhleC

                1,829720




                1,829720

















                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen