Save in File Chooser images or animations

has anyone knows how can save an image as jpg or as animations?
i use a simple code as
     BufferedOutputStream out = new BufferedOutputStream(new
               FileOutputStream(args[1]));
          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
          JPEGEncodeParam param = encoder.
               getDefaultJPEGEncodeParam(thumbImage);
          int quality = Integer.parseInt(args[4]);
          quality = Math.max(0, Math.min(quality, 100));
          param.setQuality((float)quality / 100.0f, false);
          encoder.setJPEGEncodeParam(param);
          encoder.encode(thumbImage);but it not save my image
thanx

maybe you need to flush or close the encoder? I forget offhand.
it should save... are you sure of what args[1] is?

Similar Messages

  • How to save HTML file with images present in the server to local machine

    Hi all
    In my application i have a option for the user to save HTML files with images present in the server. The HTML file is getting saved but the images are not being saved.
    The code i am using is below :-
    l
                        File fname = new File(filePath);
                        if(!fname.exists())                return;
                        FileInputStream istr = null;
                        OutputStream ostr = null;
                        response.setContentType("application/"+format);
                        response.setHeader("Content-Disposition", "attachment; filename=\"" + fname.getName() + "\";");
                        try { 
                             istr = new FileInputStream(fname);
                             ostr = response.getOutputStream();
                             int curByte=-1;
                             while( (curByte=istr.read()) !=-1)
                                  ostr.write(curByte);
                             ostr.flush();
    Can anyone suggest what i need to do
    regards

    The client should probably parse the html that comes down, and look for <img> links, and request those of the server as well.

  • How do you open and save PNG files as images rather than a document (which my MacBook is doing automatically)?

    Hi,
    Basically I'm doing a course in which i need to import images on a document for evidence (in particular Cirque Du Soleil, yes it's a weird course!) I am using the develop menu tab and using the Inspect Element menu. Here i have found loads of images that are perfect for my evidence, but the images are all showing as PNG files. Whenever I try to save these they will only save as Documents and not images. How can I change this so I can save them as images and import them imto Pages.
    Many Thanks
    Mason

    Hi @Shootist007
    I knew PNG files were image files, that why i was confused when I saved them onto my Mac they were showing as Documents under file type. But i managed to do via Preview (opened it up in Preview then click and dragged to my document).
    Thanks for your help

  • I'd like to save to file/database image from clipboard

    Hi, I've got following problem.
    In my swing application I would like to pase image from clipboard (f.ex. copied from msword). I use following code to do that:
    TransferHandler handler=jLabel.getTransferHandler();
    handler.importData(jLabel,clipData);
    Then I want to save image to database.
    I know it should look like this:
    ImageIO.write(RenderedImage im, String formatName, OutputStream output);
    But how to transform image from clipboard or graphics from jLabel1.getGraphics into RenderedImage ???
    thanx in advance !

    Starting with the original image I adjusted the levels (Image>Adjustments>Levels (Ctrl L) to the following settings:
    Then using the marquee tool I selected the areas not in use and filled with white:
    Till you get something like this:
    Then I used the brush tool to fill the other bits of the lines in white using these settings:
    Once you are happy with the result with a white background go to the Blending Options on your layer:
    and set the blend as below and press ok:
    This will make your layer look like its got a transparent background, then create a new transparent layer and place underneath:
    When you have done this combine the 2 layer by selecting both and then right click and merge layers:
    After these steps save as a .psd file then you can copy anything you need from this file.
    I hope this all makes sense and you get the result you want. Like I said fiddly! :-)
    End result:

  • When a user rasterizes a color image in AI and copies into Excel and saves file the image is BW

    When a user rasterizes a color image in Illustrator and then copies it into Excel and saves the file the image turns black and white. I uninstalled and reinstalled the whole suite already, deleted the perference files that i could find. and also look at the rasterizing settings they are the same as mine and another user. Any other things I can try? Where are the default rasterize settings stored at?

    You can do a save for web and choose .png or ,jpg format. Uncheck transparency.

  • Ever time i save a file in jpg it saves the file that was 4 to 5 meg to 720 kb

    i
    am a photo stock photographer when i down load my files from my
    camera they are between 4 to 5 meg in size
    but when i bring up in photoshop to edit them after i save them
    in jpg as format cus
    tomer wishes they save in a 720kb or less file size i need thes files to be at least 4 meg in size so what am i doing wrong?

    I am sorry, it is very difficult to understand exactly what you are asking.
    When you download files from your camera to Photoshop they are large, several megs.
    JPEG's coming directly from a camera for the most part have very little compression applied to them as so are much larger file size then an editing application would save them as.
    Now if I am understanding correctly you are attempting to compress the images to 740 k or less per image.
    When you choose the save the file, choose file>save as and choose jpg from the drop down and select OK.
    You will get a box with jpeg options, it is from that box you can select in the image options section  the amount of compression you want applied to the JPG the more compression the smaller the file size. keep in mind too much compression starts to produce jpeg artifacts and distortions so not too much compression.

  • Flash freezes up everytime it saves the file

    When I have a file with more than 30 keyframes it starts freezing every time I save the file or it auto saves. The more I work the longer it takes to save the file. This interrupts my work to an extremely frustrating level.
    Is there a reason for this?
    I'm not working on a super powered machine but I don't think I should have this problem. I have:
    -Surface Pro (First gen)
    -Windows 8.1
    -i5 1.7GHz
    -4 GB RAM
    -128 GB HDD (80 available)
    -Flash CC 13.1.0.226
    Is there a setting in Flash or Windows 8 that I can change to fix this problem?

    I am sorry, it is very difficult to understand exactly what you are asking.
    When you download files from your camera to Photoshop they are large, several megs.
    JPEG's coming directly from a camera for the most part have very little compression applied to them as so are much larger file size then an editing application would save them as.
    Now if I am understanding correctly you are attempting to compress the images to 740 k or less per image.
    When you choose the save the file, choose file>save as and choose jpg from the drop down and select OK.
    You will get a box with jpeg options, it is from that box you can select in the image options section  the amount of compression you want applied to the JPG the more compression the smaller the file size. keep in mind too much compression starts to produce jpeg artifacts and distortions so not too much compression.

  • Save in file location?

    Hey all. I'm really confident with actions, but new to scripting. I'm looking write something to 'save as' a file into the open file's location. So whatever file I'm working on, when I run the action or script it will save to the current folder. I haven't found a way to do this with actions so I want to know if I can with scripts.
    For example, on the desktop I have a test1 folder and test2 folder. I can record an action to save an open image from test1 to test1, but then open images from test2 go back into test1. My work around right now is another action (file/automate/batch) to run the saving action and open the dialog box where I can direct it where to save.
    I appreciate any help.
    -Matt

    Just remember if you do delete and replace files you could possible loose something you can not recovered except from backup which you may on may not have.  An other approach would be to rename the original file for possible deletion. Like rename original.ext to original.ext.4deletion. Neither way is ideal for both ways have a problem.
    Remember if in a folder there are different file type with like name for example original.jpg and original.PSD and a Image Processor Pro run was setup to save PSD files for image files in that folder.  When the jpeg file is processed the like named psd file would be deleted or renamed by the mod made.. Then a new originalname.PSD would be saved with the modifications made to the jpeg document.  Then that new originalname.PSD would then be processes by the script for that file would be in the list of files to process. So the new originalname.PSD would be opened and processed deleted or renamed and a new new originalname.pds with a different modification would be saved.
    What you wind up with using the delete mod is your original.jpg and an originalname.PSD That may be nothing like you wanted and your original layered PSD file was deleted never processed and lost. If you used the rename approach the script should fail during the second rename when it tries to rename the new originalname.PSD to originalname.PSD.4deletion for that file now exists.
    If the file list has a different sort order where the psd file is processed first the Layered PSD file still gets deleted and and replaced with the modifications made to the jpeg document a file you wanted and you still have your original jpg file and the original psd file is still lost.  The rename mod should still bomb on the second rename.
    There is no easy solution for often you save different file type for an image and you may have then a single folder. Paul's picture processor has a an source image file type filter you may be able to use his processor to filter a source file type extension and save the same file type. Maybe even replacing source files. I have not tested it.
    Picture Processor II dialog:
    I just did a quick test and Paul's Picture Processor can be used to filter file types and replace the filtered files.
    Source folder = target folder jpg to jpg test dialog settings
    http://www.ps-bridge-scripts.talktalk.net/
    Download Zip File
    bridge support
    Download Zip File
    Message was edited by: JJMack

  • While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything.

    While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything. This is becoming incredibly frustrating. It happens at random time and a restart of the computer is all that helps, then with out any notice it starts to do this again.  Mac Book Pro i7 2.2 16 GB 1333 Ram, (2) 450GB SSD both internal to machine. At this point I am losing file because I am unable to save in the file type I need. Does anyone out there know how to solve this issue?
    Thanks
    phil

    I haven't been unify photoshop much in the past month, but I did try your suggestion and it seemed to work for a while. Today when i went to save a document the same thing happened: click on file>save at this point I can not click on save even though it is highlighted. Tryed to use command s that brings up the save dialogue box, but when I try to change file type I again cannot select it from the drop down menu.

  • I have used Image Capture to scan images/documents and then saved them as either PDFs or PNG files.  For some reason, just this past week Image Capture will no longer save the file.  It scans, and the Scan Results window pops up, but it won't save file.

    I have used Image Capture to scan images/documents and then saved them as either PDFs or PNG files.  For some reason, just this past week, Image Capture will no longer save the file.  It scans, and the Scan Results window pops up, but it won't save file.
    The file name has no special character in it, just letters and no spaces.
    I have done this in the past and it has worked, but now it will not.
    I have not upgraded any software, that I am aware of.
    After scanning, the Image Capture pops up the Scan Results with the file name in the window, but neither the Scan Results nor the Image Capture window responds to inputs.  The Image Capture window is frozen, with only the "Overview" and "Cancel" buttons active (but non-responsive).
    Is this a software issue or a scanner hardware issue?  I am using a HP Photosmart C6200 series printer/scanner on a network using a Time Capsule airport.
    Thanks.

    I had the same problem.
    Got a 90% fix.  Apparently the Mavericks preferences won't work with Yosemite, so I just deleted the Image Capture preferences.
    Unfortunately, the "Scan to" folder seems to be permanently set to the Pictures folder.
    1.  Quit Image Capture
    2.  Go to Finder > Go > Home, which opens up your home folder (named after your user name)
    3.  Open Library > Preferences > com.apple.ImageCapture.plist - Drag this file to the Trash
    4.  Start "Image Capture", click "Details" and change all your settings as you prefer
    5.  Quit and restart "Image Capture".   Notice it remembers all your settings except "Scan to" folder.  It insists on saving to "Pictures".
    That's as far as I was successful.  I tried changing the "Scan to" folder to "Desktop", but on launch, Image Capture always sets it back to "Pictures".
    This is what I tried:
    6.  Download and install "Pref Setter" from http://www.nightproductions.net/prefsetter.html
    7.  Quit "Image Capture".  Right-click on "com.apple.ImageCapture.plist" and open with Pref Setter.
    8.  Search for "Pictures", which finds "~/Pictures" (the tilde character at the start means your home directory).
    9.  Double-click on "~/Pictures" and change it to the folder you prefer.  I like "~/Desktop"
    10. Choose File > Save then Quit from Pref Setter.  Note that re-opening the plist file still shows "~/Desktop"
    11. Start up "Image Capture" -- on startup, "Image Capture" sets "Scan to" folder to "Pictures"
    I consider this a bug.

  • When I try to same an image under the command 'save as' it will only let me save as file types 'firefox document' or 'all files' and when I try to look at them later they dont work. How can I save an image as the same file type it is on the web site?!

    When I try to save an image under the command 'save as' it will only let me save as file types 'firefox document' or 'all files' and when I try to look at them later they dont work. How can I save an image as the same file type it is on the web site?!
    == This happened ==
    Every time Firefox opened
    == I updated to one of the firefox versions (Not sure which one it was)

    Thanks Alex, but sadly I already tried that. Neither .docx or .xlsx files show up in the content list. They both show as a Chrome HTML document so changing how Firefox addresses those doesn't help since it thinks its the same type of file. I don't think I can manually add files into the "Content Type" left side nav.

  • IMac (27-inch, Mid 2011) 2.7 GHz Intel Core i5 4 GB 1333 MHz DDR3 running10.10.2 (14C1514). Trying to install Windows 7 64 bit from an install disc. When attempting to create an ISO image I can save the file in disk utility but can convert cdr to iso

    iMac (27-inch, Mid 2011) 2.7 GHz Intel Core i5 4 GB 1333 MHz DDR3 running10.10.2 (14C1514). Trying to install Windows 7 64 bit from an install disc. When attempting to create an ISO image I can save the file in disk utility but can convert cdr to iso. I select the file and the hit return as in step 8 of the Creating an
    iSO image document but the box that should open to select use iso does not open. How should I proceed?

    The Mac SuperDrive built into your Mac is the Optical drive.
    1. Insert your Windows DVD in Optical drive. Disconnect any external storage.
    2. Insert a USB2 Flash drive. This will be used to hold the BC drivers.
    3. Start BCA. Check the options to download software and Install Windows. You do not need to download Windows. The BCA will download the BC drivers to the USB.
    4. Partition your drive.
    5. You can see the Windows installer screens at https://help.apple.com/bootcamp/mac/5.0/help/#/bcmp173b3bf2.

  • Need help adding a default file name in a file chooser of save dialog type

    I need to create a file chooser with save dialog type, how can I add a highlighted default file name into the File Name textfield? As in Microsoft Word, when you want to save a document, a default file name Doc1.doc will appear in the File name text field of the file chooser even when you change to other directories.

    For JRE 1.4.0 you can use this fix:
    public class FileChooserFix implements PropertyChangeListener {
      private String fileName;
       * @see PropertyChangeListener
      public void propertyChange(PropertyChangeEvent ev) {
        JFileChooser chooser = (JFileChooser)ev.getSource();
        if (JFileChooser.FILES_ONLY == chooser.getFileSelectionMode()) {
          if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            File selectedFile = (File)ev.getNewValue();
            if (selectedFile != null) {
              // remember fileName of selected file
              fileName = selectedFile.getName();
          if (fileName != null &&
              JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            // reset selected file
            File directory = (File)ev.getNewValue();
            chooser.setSelectedFile(new File(directory, fileName));
       * Convenience method to create a fixed file chooser.
       * @return      fixed file chooser
      public static JFileChooser create() {
        JFileChooser chooser = new JFileChooser();
        chooser.addPropertyChangeListener(new FileChooserFix());
        return chooser;

  • File chooser to buffered image

    Hi all,
    Sorry about the total newbie question; I'm trying to figure out how to convert a jpg into a buffered image, while using the file chooser to select it. I'd like to do all this in a scrollpane. Does anyone have some sample code for this, at least so I can play around? I have ideas, but I'm getting tons of errors while trying things like:
    public class ImProc extends JComponent{
    private BufferedImage source, destination;
    private JComboBox options;
    public ImProc( BufferedImage image){
    source = destination = image;
    setBackground(Color.white);
    setLayout( new BorderLayout());
    JPanel controls = new JPanel();
    options = new JComboBox(
    new String[] {"[source]", "brighten", "darken", "rotate", "scale" }
    options.addItemListener(new ItemListener(){
    public void itemStateChanged( ItemEvent ie){
    String option = (String)options.getSelectedItem();
    BufferedImageOp op = null;
    if(option.equals("[source]"))
    destination = source;
    else if(option.equals("brighten"))
    op = new RescaleOp(1.5f, 0, null);
    else if(option.equals("darken"))
    op = new RescaleOp(0.5f, 0, null);
    else if (option.equals("rotate"))
    op = new AffineTransformOp(
    AffineTransform.getRotateInstance(Math.PI / 6), null);
    else if (option.equals("scale"))
    op = new AffineTransformOp(
    AffineTransform.getScaleInstance(.5, .5), null);
    if(op != null) destination = op.filter(source, null);
    repaint();
    controls.add(options);
    add(controls, BorderLayout.SOUTH);
    public void paintComponent(Graphics g){
    int imageWidth = destination.getWidth();
    int imageHeight = destination.getHeight();
    int width = getSize().width;
    int height = getSize().height;
    g.drawImage(destination,
    (width - imageWidth) / 2, (height - imageHeight) / 2, null);
    public static void main(String[] args){
    JFileChooser chooser = new JFileChooser();
    String filename = chooser.getName();
    ImageIcon icon = new ImageIcon(filename);
    Image i = icon.getImage();
    int w = i.getWidth(null), h = i.getHeight(null);
    BufferedImage buffImage = new BufferedImage(w, h,
    BufferedImage.TYPE_INT_RGB);
    Graphics2D imageGraphics = buffImage.createGraphics();
    imageGraphics.drawImage(i, 0, 0, null);
    JFrame frame = new JFrame("Image");
    frame.getContentPane().add(new ImProc(buffImage));
    frame.setSize(buffImage.getWidth(), buffImage.getHeight());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    So, I'm stuck. Any help from anyone is appreciated.
    Thanks,
    Joe

    Now, with:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    import java.io.*;
    import javax.imageio.*;
    public class ImProc extends JComponent{
    private BufferedImage source, destination;
    private JComboBox options;
    public ImProc( BufferedImage image){
    source = destination = image;
    setBackground(Color.white);
    setLayout( new BorderLayout());
    JPanel controls = new JPanel();
    options = new JComboBox(
    new String[] {"[source]", "brighten", "darken", "rotate", "scale" }
    options.addItemListener(new ItemListener(){
    public void itemStateChanged( ItemEvent ie){
    String option = (String)options.getSelectedItem();
    BufferedImageOp op = null;
    if(option.equals("[source]"))
    destination = source;
    else if(option.equals("brighten"))
    op = new RescaleOp(1.5f, 0, null);
    else if(option.equals("darken"))
    op = new RescaleOp(0.5f, 0, null);
    else if (option.equals("rotate"))
    op = new AffineTransformOp(
    AffineTransform.getRotateInstance(Math.PI / 6), null);
    else if (option.equals("scale"))
    op = new AffineTransformOp(
    AffineTransform.getScaleInstance(.5, .5), null);
    if(op != null) destination = op.filter(source, null);
    repaint();
    controls.add(options);
    add(controls, BorderLayout.SOUTH);
    public void paintComponent(Graphics g){
    int imageWidth = destination.getWidth();
    int imageHeight = destination.getHeight();
    int width = getSize().width;
    int height = getSize().height;
    g.drawImage(destination,
    (width - imageWidth) / 2, (height - imageHeight) / 2, null);
    public static void main(String[] args){
    JFrame frame = new JFrame("Image");
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    JFileChooser chooser = new JFileChooser();
    //String filename = chooser.getName();
    File f = chooser.getSelectedFile();
    //String filename = f.getName();
    //ImageIcon icon = new ImageIcon(filename);
    //Image i = ImageIO.read(f);
    //int w = i.getWidth(null), h = i.getHeight(null);
    //BufferedImage buffImage = null;
    try{
    BufferedImage buffImage = ImageIO.read(f);
    catch (IOException e){
    System.out.println("Error: " + e.getMessage());
    frame.getContentPane().add(new ImProc(buffImage));
    Graphics2D imageGraphics = buffImage.createGraphics();
    imageGraphics.drawImage(buffImage, 0, 0, null);
    With this, it doesn't seem to find my variable buffImage. However, it complains if I don't use the try{} catch{}. Am I not declaring something properly?

  • Choosing which folder to save downloaded files to as soon as file is downloaded?

    I'm completely new to this so if there's a simple solution to this, do forgive me and thanks in advance for your patience!
    So I've just started messing about with Automator today and read about Applescript.
    I'm basically trying to find a way of having a prompt for me to select which folder I'd like to save downloaded files to, as soon as the files are downloaded into that folder.
    I've tried a couple of things:
    Setting up a Folder Action in Automator for my Downloads folder.
    'Revealing items in Finder'
    'Get selected items in Finder' (thinking that this somehow grabs the items that were revealed and selected in the previous step)
    Then running an Applescript (as an 'action' in Automator) to do something like this:    
    on adding folder items to this_folder after receiving these_items
      tell application "Finder"
      set the destination_folder to [choose folder with prompt choose folder]
      end tell
    end adding folder items to
    Or something like this:
    on run {input, parameters}
      tell application "Finder"
      select files
      move files to [choose folder with prompt choose folder]
      end tell
      return input
    end run
    As you can probably tell, I really haven't a clue (although this is addictive and I can't deny I'm enjoying myself)... I've tried a few more variations based on scripts I've seen dotted around the web doing similar things but I didn't hold on to them so I can't show you them. The script  actually runs really smoothly, and runs through with no errors - I copy a file into my downloads folder (to test) from another folder. The Downloads folder opens up automatically, selects and shows me the file I've just added then pops up with the window prompting me to choose a folder. It's just that when I do end up choosing the folder, the file doesn't move at all. The window disappears then pops back up again, then disappears after I press 'Choose' for the second time, as though something has happened. I suppose the files that the Finder revealed, selected and 'got' had no connection to the following action/script?
    What do I need to change? As I said, completely new to all of this so please do treat me like I'm a bit stupid!
    Thanks!

    Others have already given alternative pointers to solve your specific problem, but I can understand the desire to roll your own
    From your script samples, you're on the right track, but are missing a couple of key concepts. I'll try to clarify.
    Your script:
    on adding folder items to this_folder after receiving these_items
      tell application "Finder"
      set the destination_folder to [choose folder with prompt choose folder]
      end tell
    end adding folder items to
    First up, let's correct that 'choose folder' command. Specifically, the prompt - it should be a string (enclosed in quotes). As it stands, conceptually, you're kind of invoking 'choose folder' again, and the result of that is used as the prompt on the first 'choose folder'. Not going to work so well.
    Instead, your choose folder should look more like:
      set the destination_folder to choose folder with prompt "Select a folder:"
    Note how I've quoted the text and now it's interpreted correctly - the selected folder will now be stored in destination_folder.
    Now that you have the destination folder, what you need is the files to move. Fortunately, Folder Actions provide this for you in the way the command is called:
    on adding folder items to this_folder after receiving these_items
    In this case, these_items is a list of the newly added files., so all you need to do is move these files to the destination_folder:
    on adding folder items to this_folder after receiving these_items
      set the destination_folder to choose folder with prompt "Select a folder:"
      tell application "Finder"
      move these_items to folder destination_folder
      end tell
    end adding folder items to
    Note how I've moved the 'choose folder' line outside of the 'tell application "Finder"' block - there's no need for it to be in there, and this way it will prevent the context switch where the Finder comes active to ask you for the folder.
    Incidentally, this is a 'pure' AppleScript implementation, not an Automator action. The Automator action would be radically different in that the files would be passed into your workflow - you'd need to store these in a variable, then prompt for the destination folder and store that in another variable, then use the move Finder items action to move the files, like:
    Personally, I prefer the AppleScript option

Maybe you are looking for