Save to jpeg

hi all,
i tried to save a jlayeredPane to a jpeg; all the compnents are saved but the background dirty, i mean wth different kind of fragments of images, and i don't know from where;
how can i save a jpeg with the background clear ?
Himerus
thanks in advance

Works for me:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class ComponentSaver {
    public static void save(Component comp, File file) throws IOException {
        file.delete();
        int w = comp.getWidth();
        int h = comp.getHeight();
        BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = bi.createGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, w, h); //clear
        comp.paint(g);
        g.dispose();
        ImageIO.write(bi, "jpeg", file);
    public static void main(String[] args) {
        final JFrame f = new JFrame("ComponentSaver");
        JButton save = new JButton("save");
        save.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent evt) {
                try {
                    save(f.getLayeredPane(), new File("junk.jpeg"));
                } catch (IOException e) {
                    e.printStackTrace();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container cp = f.getContentPane();
        cp.add(new JLabel("sample label"), BorderLayout.CENTER);
        cp.add(save, BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
}

Similar Messages

  • How to default save as JPEG?

    My current workflow has been placing rectangular photos onto white square backgrounds and then saving as JPEGs. Each time I have to save the resulting image, I have to manually opt for JPEGs. Is there any way of making this a default? Thanks if anyone knows.
    Richard

    When you have several layers, a jpeg format can't save your work, you have to create another file in psd or tiff format to keep the original unchanged and a new file with layers as a copy.
    The normal use of the 'save' command is to overwrite the original image. What you really want is not a single step, it's to:
    - flatten the layers
    - save (overwrite) the original image file.
    Allowing a default to automatically do that when you are editing a layered file would be a disaster in most cases. So you have two ways to tell the software to do that:
    - specify the jpeg format as output and if you want to overwrite the original or create a copy or version set
    - do a 'flatten image' before trying to do a 'save' or 'save as'.
    (If you use 'save for web', you are implicitly telling you want to flatten and save as jpeg).

  • My images won't save as jpeg unless I go to Save As... what is happening to my images?

    My images look great when edited in photoshop and when I got to close and save it won't give me the option to save as a jpeg so I have to go to File Save As and then save to jpeg. But when I go to order them in Roes they look drab and awful but the thumbnail looks great. Am I saving it wrong somehow?

    Go to Image --> Mode and set image to 8 or 16 bit. If the image has 32 bit, it won't export through the save for web dialog.
    Let me know if this fixes the issue.
    Reidar

  • I edit my photos in Photoshop, save as jpeg then import back into iPhoto.  But if I add text to an image in Photoshop can't save as jpeg but as psd. Is there any way I can change to jpeg in iPhoto?

    I edit my RAW photos in Photoschop CS3, save as jpeg then import back into iPhoto 11.  If I add text in Photoshop I can't save as jpeg but as psd.  Is there any way I can change to jpeg in iPhoto?

    Terence Devlin wrote:
    Yes you can. But you need to flatten it as jpeg doesn't support layers.
    While the final JPEG can't have layers, it is not necessary to flatten the original Photoshop file to create a JPEG. There are two ways to make a JPEG while not losing the flexibility of preserving layers, and they both flatten on the fly while saving.
    I just tried this in Photoshop CS3 myself. When I add a text layer, and choose Save, the Save As dialog box comes up and defaults to PSD as was described. But... that is just the default! Go ahead and choose JPEG from the Format pop-up menu down below the file list. JPEG is in there. So what happens to the layers? Notice when you choose JPEG, the Layers box grays out and the "As A Copy" box grays out and is checked (i.e. you cannot uncheck it). What is going on here is Photoshop will gladly make a JPEG of your layered file, but it will force the JPEG to be a copy, so as to not overwrite the original layered file. This is good, because your Photoshop file with its editable text layer is preserved, and you get a JPEG copy to put in iPhoto.
    The second way is, instead of doing Save or Save As, choose File/Save for Web and Devices. This will also give you a JPEG choice, and also create an exported copy. Because this way makes files for the Web, they will be smaller than JPEGs from Save As because they will lack built-in previews (which you don't really need these days) and other extra metadata that take up space.
    Either way you get a JPEG you can toss back into iPhoto.
    Terence Devlin wrote:
    Only by exporting.
    The Export menu in Photoshop CS3 does not have any direct choices for JPEG.

  • One-click 'Save as jpeg' shortcut script please! - saved in the same folder

    Hi, I've been re-directed here because I was told a script could solve my problems - but I have no scripting experience/knowledge/ability! Below is my original problem and post. I got as close as 2 button presses, but I'm after that sweet, sweet single-button, double-my-productivity shortcut! Thanks!
    http://forums.adobe.com/thread/1106992
    I use 'Save as .jpeg' ALL the time (Photoshop CS6, Mac ML), and it really feels like I should just be able to press one button (a shortcut) and the name/quality dialogs don't appear and it just saves a .jpeg into the folder that my original .PSD/file is in.
    So basically:
    - Press one button to save my open .PSD/file as a .jpeg
    - Automatically save it in the same folder as my .PSD
    - Save it as '10' quality in the jpeg settings
    - No dialog boxes, as soon as I press the button, it saves it - if there's already a .jpeg of the same name, it creates a '-1','-2' etc.
    I've tried using 'Actions', but it seems to save it wherever my original Action folder was - it doesn't change to whatever the current folder the .PSD is in...
    Thanks!
    Adam

    File -> Scripts -> Script Events Manager
    Click Enable Events at the top
    Select Save Document from Photoshop Event  drop down
    Select Save Extra JPEG from Script drop down
    Click Add
    Click Done
    EVERY document you save, except JPEG files, will save a jpg file. Saving will be slower.
    You will need to modify line 62 of the Save Extra JPEG.jsx file located here: <YOUR_PHOTOSHOP_INSTALL_LOCATION>\Presets\Scripts\Event Scripts Only
    In order to boost your quality to '10'. Here is the line in question
    jpegOptions.quality = 2; // really low
    Change it to
    jpegOptions.quality = 10; // really high
    You will need to modify the script to get this problem solved as well: it saves it - if there's already a .jpeg of the same name, it creates a '-1','-2' etc.
    You can steal code out of Image Processor that finds a file name that is unique for the folder so you don't get overwrites.
    Are you sure you want that? If you do lots of saves you are going to fill up your disk fast.

  • Batch Process Export As and Save As JPEG Question?

    What is the method for creating scaled JPEGs from PNG files with batch processing (File | Batch Process...)?
    Application environment: Fireworks CS4.
    Using History panel, I manually captured instructions
    Modify | Transform | Numeric Transform (13%)
    Modify | Canvas | Fit Canvas
    File | Save As (JPEG)
    History panel's saved JavaScript file script:
    fw.getDocumentDOM().scaleSelection(0.11999999731779099, 0.11999999731779099, "autoTrimImages transformAttributes");
    fw.getDocumentDOM().setDocumentCanvasSizeToDocumentExtents(true);
    fw.saveDocumentAs(null, true);
    Running this sequence as a batch job requires manually selecting JPEG and "okaying"
    CS4 documentation for saveDocumentAs is defined with different argument list: fw.saveDocumentAs(document) .  CS4 documentation also has: fw.exportDocumentAs(document, fileURL, exportOptions) to export JPEG (80% quality).  CS4 feature File | Image Preview... | Export does not create a history record for guidance.  I cannot find an example of either instruction save a file to a local folder in JPEG format.  My objective is to add an additional batch step Rename (prefix) for the JPEG output, and script this a a batch process.

    Joyce,
    Thank you.  Your suggestion helped clear my mental log jam.
    Fireworks batch scripting seems to work in reverse.
    Using "Batch Process..." scripting interface 'Export' (as JPEG) option first, 'Rename' (add Prefix) option second, and then follow these by using the history panel's 2 previously saved steps (Numeric Transform, Fit Canvas), batch process now works.  PNG file (list) is saved in targeted folder as a reduced scale JPEG with a prefixed file name.
    Batch Process allows the entire newly defined command sequence to be saved (script.js).  Placing this (renamed) file into Firework's batch look-up directory for scripts (C:\Documents and Settings\account_name\Application Data\Adobe\Fireworks CS4\Commands) does not work.  The file name does not display in "Batch Process" window "Batch options:" Commands drop-down list.
    Batch Process only works by recreating the above steps each use.
    The new (JavaScript) file is 26 KB.  Is script file size limited in Fireworks "Batch options:" feature?

  • XY Graph Won't save to JPEG when Black and White...and run from TestStand.

    I am creating an XY graph and manipulating the colors of the plots, background, etc.  I am saving this graph to JPEG using the Write JPEG File vi and after it is saved I import it inot a test report.  This works fine in color, but when I create a B&W plot, it won't save to JPEG.  Let me clarify:  It won't save to JPEG when I run the VI from TestStand.  It does save to JPEG when I run the VI as a stand alone application in LabVIEW. 
    Problem:
    Run VI from LabVIEW ~ Saves the JPEG in both Color and B&W.
    Run VI from TestStand ~ Saves the JPEG in Color, but does not save the JPEG in B&W.    
    Here is how I am making all the plots and background B&W in my code:
    Change all Active Plots to Black using property node.
    Change all Active Cursors to Black using property node.
    Change the Plot BG colors (major/minor grids, etc) to lighter colors using property node. 
    Does anybody have any suggestions? 
    Thanks in advance,
    Mike

    A few questions: What version of LV are you using? How are you getting the control image that you are sending to the JPG? Third what exactly happens when you try to save the B/W image under TestStand? Error?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • I created a broacher with a template using pages but am unable to save it in JPEG. I tried saving as a pdf then using preview save as JPEG but it did not give that option??

    I have created a boucher with PAGES  using a template. How do I now get that teplate to JPEG?
    I tried convertong it to a PDF then saving , but I never got an option to save as JPEG.
    Appreciate any assistance.

    What version of Pages?
    Peter

  • I upgraded to mac 0sx 10.92 now i dont have the feature in my drop down to save as jpeg or save pdf to iphoto

    I upgraded to mac 0sx 10.92 now i dont have the feature in my drop down to save as jpeg or save pdf to iphoto

      This forum is for Mac Pro machines, which are desktop Macs.  You have a Macbook Pro, which is not a desktop Mac.
      Try the Macbook Pro forum.
    https://discussions.apple.com/community/notebooks/macbook_pro

  • I want to know how to turn a word document into a jpeg so I can put the document on Facebook as a picture. I have made posters and if I do a print screen they are unable to be read, or if i turn it into a PDF there is no save as jpeg??

    I want to know how to turn a word document into a jpeg so I can put the document on Facebook as a picture. I have made posters and if I do a print screen they are unable to be read, or if i turn it into a PDF there is no save as jpeg??

    iOS device backups are stored in your iTunes library.
    Move your iTunes library to an external drive.

  • How do I edit RAW photos and save as jpeg?

    HI! I have some RAW photos that I want to edit and save as jpeg. Will the edits compromise the file and how do I then save these edited files as jpegs and will that compromise the files? THANKS!

    What do you mean by “Will my files be compromised“?
    When you edit a photo with iPhoto you’re Original file is preserved exactly as it is, there are no changes made to it whatever.
    will I be able to make a readable disc?
    Why not? But what do you mean by “readable” Readable by who?
    Regards
    TD

  • Save as Jpeg

    I have created a picture with about three or four layers, a PSD file now. It is a panoramic shot I added a layer to make stars. When I try to save the file from a PSD file to a Jpeg one of the layers disappears. I have tried to save it as a tiff and then to Jpeg but still it will not save without losing the layer. It is 8 bit RGB so it's not that. I also tried to flatten the layers but still it will not save right. Anything else I can try?
    I have the background layer, a stars layer with a layer mask and a levels layer grouped and the a hue/saturation layer. This happened to me a long time ago but I can't remember if I ever fiqured out the problem.

    What you say you want is normal operation:  What you see while working in Photoshop is what you should get when you save as JPEG.  Layers should NOT be going away.
    If you're willing to share the PSD publicly, others can try to reproduce the problem...  One way to share very large images is to sign up for a free YouSendIt.com account, send the PSD to yourself, then post the URL here.  I know I'll be happy to take a look at it.
    In the interim, what happens when you do this:
    1.  Layer - Flatten.
    2.  File - Save As - JPEG.
    3.  In the HISTORY panel, go back to the step just prior to Layer - Flatten.
    This could possibly serve as a workaround.
    -Noel

  • Save as JPEG changes CMYK colour

    Hi,
    I have a solid colour in Photshop that I set CMYK values for (I work in CMYK image mode). When I save as JPEG, the resulting JPEG file changes one of the CMYK values by 1 percentage point. When I save as TIFF, it works fine (CMKY values match original photshop file). What is going on?
    This is for CS4.
    Thanks.

    I'm confused. If your goal is to print the image, why not open the jpeg in Photoshop, do a save as using the native .PSD Photoshop file format, and just continue to work and save in that file format? Going back to jpeg makes no sense.
    In the first place, Jpeg does not support the CMYK color space, so every time you save it, it will save in the much smaller sRGB space. Also, between this and the fact that it compresses the image even at the highest settings, you are going to get changes in the image, including in the colors.
    Just avoid all this and work in .PSD file format.
    Another point: all of the photographers I know usually work in an RGB color space, Adobe rgb for example. As I understand it, CMYK is used in graphics and publication, often because you want to split the image into four channels to use in commercial four-color offset printing.
    If you're going to be doing inkjet printing, or via a service, I'd suggest staying in an Rgb workspace--you can still decide to use the CMYK menu to select your colors.
    Color management can be tricky, so I'd suggest you do a bit of research.

  • Why are photos save as .jpeg instead of .jpg?  Can this be corrected?

    Why are photos save as .jpeg instead of .jpg?  Can this be corrected?  In certain applications I have to manually change the ending so that the application can open the photo.  Is there a setting to control to correct this?

    When I mail photos (via GMail) from my iPhone they are received on my PC as .jpg files, even if sent at full resolution.  Perhaps your e-mail service has imposed an attachment size limit, and in the process scales the attached picture down and alters the file extension?
    What happens if you e-mail a photo from your iPhone and open the message from a PC instead of the Surface?  What e-mail service are you using? (e.g. your ISP's service, or Yahoo, Gmail, iCloud, etc.)  When you send the photo from your iPhone, are you selecting a reduced resolution?

  • Save as Jpeg - icon

    Using a Mac with 10.4.11, CS3 and Acrobat 8.1.2
    I usually make PDFs from Quark or Illustrator, using Distiller then Acrobat.
    If I take a PDFs which originally looks like this:-
    If I do a "Save as Jpeg", the Preview icon on the desktop always looks like this (you can just see the image very feintly)
    The actual Jpeg image is ok, but it's just the Preview icon which always comes out like this
    Any suggestions?

    Hi,
    Have you installed the latest software from the HP site or may used the original CD?
    If you may used the original CD, follow the Uninstall once again, then download and install the latest software below:
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=mp-109384-2&cc=us&dlc=en&lc=en...
    Hope that may help,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Is there anyway to suppress or disable the save as jpeg options dialog box on individiual images/pic

    Is there anyway to suppress or disable the save as jpeg options dialog box on individiual images/pictures?

    UI dialogs are an application setting, not a file property. Selectively suppressing them on a per-file basis is not possible, but you can of course create an action and suppress the dialogs...
    Mylenium

Maybe you are looking for