Saving JPEG images in a batch process

Please, I need help....
I'm making an application that loads an image, perform some manipulations and save it into a JPEG file..
The code I use to paint that image to a Graphics object is this:
          public void paintToImage(Graphics gr){               Graphics2D g = (Graphics2D)gr;               //CONFIGURO O RENDER PARA SER O MELHOR POSS?VEL                g.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);               g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_QUALITY);               //seto o clip rect               g.setClip(0,0,w,h);               //pinto o fundo de branco               g.setColor(Color.white);               g.fillRect(0,0,w,h);               if(img==null)return;               g.drawImage(img, -origemXY.width, -origemXY.height,this); //'this' means an instance of my JPanel          }I call this method to paint my image into a BufferedImage this way:
     BufferedImage bi = new BufferedImage(myComponent.width,myComponent.height, BufferedImage.TYPE_INT_RGB);     myComponent.paintToImage(bi.createGraphics());If I call it to a single image (like an ActionEvent for a selected image) it works fine...
But when I try to call it from a batch process, like a loop to paint several selected images, it aways produces a white JPEG.
All the code inside my "paintToImage()" method works fine but the line "g.drawImage(img, -origemXY.width, -origemXY.height,this);".
I know that because if I use "g.setColor(Color.red)" instead of "g.setColor(Color.white)" it produces a red JPEG.
Could it be a proble with the ImageObserver that I'm using?
The method below is invoked to save several images selected in a JTree, but it only produces white Images:
               public void actionPerformed(ActionEvent e){                    TreePath paths[] = filesTree.getSelectionPaths();                    for(int i=0;i<paths.length;i++){                         filesTree.setSelectionPath(paths);//this line sets the selected image that is about to be painted by my previewPane into a BufferedImage                         try{                         BufferedImage bi = new BufferedImage(previewPane.getImagePane().getPreferredSize().width, previewPane.getImagePane().getPreferredSize().height, BufferedImage.TYPE_INT_RGB);                         previewPane.paintToImage(bi.createGraphics());                         /* write the jpeg to a file */                         File file = new File("D:/VER/0000" + i + ".jpg");                         FileOutputStream out = new FileOutputStream(file);                         /* encodes the image as a JPEG data stream */                         JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);                         JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);                              param.setQuality(1.0f, false);                         encoder.setJPEGEncodeParam(param);                         encoder.encode(bi);                         out.close();                         }catch(IOException ioex){                              ioex.printStackTrace();                         }                    }               }
What is the problem?? What am I doing wrong?? any help wold be greate...
Thank's all and aloha from Brazil...

Reformat your problem, you can infinitly insert any number of '\n's here,

Similar Messages

  • On CS5, how can I recover jpeg images that were Batch Renamed prior to removal from my flashcard?

    On CS5, how can you recover JPEG images that were accidentally Batch Renamed prior to removal from a flash card? Is it a total lose or can they be saved somehow?

    If they were renamed on the flash card that is a poor practice.  If renamed in Bridge the old names can be recovered it you have checked "preserve original name in XMP".  If not you are out of luck.  But you still have the images correct?

  • Image Sequences and Batch Processing: Can opening files from different folders as image sequences be set up as an action for batch processing?

    I have an ongoing series of tasks that necessitates opening the contents of a series of folders as image sequences.
    I'm used to setting up some fairly complex actions, including ones that are intended to be applied to all of the contents of materials in various subfolders, but for some reason I cannot get an Open-with-Image-Sequence-Checked action to set up in a way that will batch process correctly.
    Complicating matters is that the file prefixes (i.e., the letters before the sequential numbers) and the folders will always have different names from the last time the process had to be carried out.
    The steps I would like the action to carry out would be the following:
    1. Open Subfolder 1 - that is, Photoshop shouldn't be looking for a specific folder. It's just *any* subfolder to the current parent folder.
    2. Select first file in sequenced set of files.
    3. Open as an image sequence.
    4. Open Subfolder 2.
    5. Select first file in sequenced set of files.
    6. Open as an image sequence.
    ...rinse and repeat until Photoshop runs out of subfolders to check.
    Am I asking the impossible?
    Thanks!

    I'll look around there,  because I had posted something about this and was told to look here ps-scripts - Browse /Image Processor Pro/v3_0 at SourceForge.net  
    then this is the image here:
    is the result I received.  Granted I'm new to using scripts and actions for image processing large amounts of files.  

  • Image matte key: batch processing possible?

    Hello again,
    I have a question concerning batch processing with Premiere Pro CS5.5.
    I would like to apply an image matte key to about 30 videos. The matte doesnt change, neither does the background photo.
    I would like to know if there's a way to apply this to all the videos at the same time.
    I have only been able to apply it to one video at a time, which means that I would have to do the same process 30 times. Because I have about 12 sets of background photos, I would have to do it about 360 times in the end. So batch processing would really help...
    I need the videos to be seperate in the end (360 videos).
    I hope someone has a solution for me. Thanks a lot in advance!!!

    Check to see if this works:
    Create and Import your Matte into PrPro. Place it on the desired Video Track, and then extend its Duration for all Clips on that Timeline. Apply the Track Matte Keying to the first Clip, and make the attributes adjustments to it. Rt-click that Clip, and choose Copy. Then lasso all other Clips in that Track, Rt-click on them and choose Paste Attributes. Does that work?
    Good luck,
    Hunt
    PS - not sure if a Nested Sequence would also do what you want.

  • Unable to open saved JPEG images

    I opened and modified several JPEG images with Photoshop CS2. Now none of these files can be opened by Photoshop or any other program. All of the files seem to have a non-zero size, but when I try to open them in Photoshop, it does not generate an error, it merely offers to create a new file with the same image properties (size, etc) as the saved image on disk.
    I've also tried several other programs to open these files, and none of them can open them. FYI, one thing that all of the files have in common is that they are all saved with the absolute minimum compression settings.
    Any assistance in helping me to recover these files would be greatly appreciated.
    Thanks.

    You can email me one of the Pics (zip it first) but it sounds like they are toast.

  • Stacking versus Collections for grouping images to be batch processed

    My typical shoot is studio portraiture, with shifting backgrounds, poses and lighting setups. I can usually batch about 25 images in a single chunk before something changes to require a new retouching approach.
    If I want to group like raw images needing similar retouching with Lightroom, should I use Stacking or Collections?
    I've read the full manual, and it's not clear to me which is the better approach. Stacking is called the approach for this in the manual, but it involves the step of unstacking or stacking. Collections seems just as appropriate.
    Appreciate any insight on which of these 2 most people use to group like images, as well as any other info on where people use stacking or collections.
    I'm Windows XP.
    Thanks
    Paul

    Each to there own.
    I see stacking as a set of images that have a distinct similarity, for example a model shoot of similar poses, what ever. the idea is to stack on top the most favorite/desired and stack under the less favs that u want to have access to at a later time, or just cant part ways with.
    I see collections as a vertual way of re-catorgorizing a set of images.
    In your case, another way might be to assign a specific keyword relevant to the light scene or touch up required, on import.
    Or use the star ratings, personal choice to a point.

  • Batch processing images of various sizes

    I'm trying to create 125 pixel square thumbnail images using a batch process and I'm having trouble getting it to work consistently with images that have different aspect ratios. I think I know why it's working the way it is, but I don't know how to work around the function. Here is what I'm doing that doesn't work when the image proportions change:
    1. Resize image to 125 pixels high using the "constrain proportions" option.
    2. Resize canvas to 125 pixels wide, thus cropping the sides to create the square image.
    Then I have another process that does the same thing with images in portrait orientation. The problem is, I have some images that are 640x480, for example, and some that are 640x360. If I create the command using a 640x480 image, the 640x360 images are skewed when run through the batch because the "resize image" step is actually setting the dimensions of the image, rather than maintaining the proportions of that particular image. I thought about setting the canvas to a square first, but since not all my images are the same dimensions, I'm not sure how to account for that.
    Anyone have any thoughts? I also have Photoshop, but as a novice, I've found Fireworks to be a little more intuitive for some of these basic commands, particularly batch processes.
    Any help would be appreciated. Thanks so much!
    Jeremy

    It seems tricker than one might expect to create square thumbnails!
    I'm a little confused by the results you're describing. When I try using Modify > Canvas > Canvas Size to crop a document, the result appears in the History panel as "Crop Document". If I select that step and choose "Copy Steps to Clipboard", then paste the results in a text file, I get something like this:
    fw.getDocumentDOM().setDocumentCanvasSize({left:16, top:0, right:141, bottom:125}, true);
    This reveals that the canvas is being cropped according to a specific bounding rectangle that may or may not be a great fit for all the other images being processed (depending on their widths). For a more foolproof result, a rectangle like {left:0, top:0, right:125, bottom:125} would be a better choice; however, aesthetically, I'd personally prefer that images be cropped from the center, not the left side.
    If I had something better to suggest here, I would. It might be worth checking out Photoshop to see if this type of operation is any easier. Here's one online tutorial on the subject: http://demosthenes.info/blog/347/PhotoShop-Batch-Processing-Generating-Image-Thumbnails-vi a-Automated-Crop-&-Resize

  • Fireworks CS4: Batch-processing fails

    Dear Helpers,  I need your advice for solving a problem concerning the batch-processing with Fireworks CS4 on WinXP. A few days before there was no problem witch "batching". But now, after choosing the image files, the batch process stops by closing the "batch"-window.  Can anybody help?  Thanks for your answers.  Oli

    Hey... solved it! Changed the background color in almost 2,000 jpegs. Heres how:
    Photoshop CS4, first define a color in an AXT file:
    Open test image, image, adjustments, replace color. use eye dropper to sample the background color, bring hue, saturation, and lightness bars all the way to the right (background color now turnd white), click save (save the definition AXT file, you will need to reference it later).
    Now create a new action called "replace color", have test image open (with original background that you want to change), start record and do this to record the action:
    Image, adjustments, replace color. Click load and select the AXT file, click load (the background color now turns white with the loaded AXT definition). Click ok. save file. Stop record action.
    Now run a batch command and use that action you just recorded: File, automate, batch, select your new action in the play section, select the folder of files to process and the destination... click ok to run the batch.
    I changed the "background" color in 2,000 estore product images of various sizes (thumbnail, medium, and large sizes) in about 15 minutes. Wow! I knew there had to be a way.
    Hope it helps lots of people, 'cause it sure is a common need.
    Cheers,
    Carl

  • Unopenable JPEG Images

    Since upgrading from Photoshop CS2 to CS5, I have been unable to open any of my saved JPEG images. When I attempt to do so, a pop-up screen appears with the message "Could not compete your request because the PICT contains data that is no longer supported in this version of Photoshop." How can I salvage these JPEG images?

    Are you sure they're JPEG images? Or are they PNG?
    This thread may help you: http://forums.adobe.com/thread/637981

  • I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is j

    I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is just a plain photoshop file, a watermark is added, then save as jpeg - the jpeg is saved to a different folder than the original photoshop file.)  It happens for about 10 of 30/40  files approximately . Thank you, Kathryn

    I believe I have figured it out - I need to flatten the image, even though there are no layers except for layer 0, first.

  • Saving as jpeg in batch processing

    Hello:
    A "newbie" here.  I have recorded an action to put a watermark on photos.  When I run the batch, instead of it saving the image and going on to the next, it opens the image at the save prompt as a pdf, and i would have to choose jpeg in the drop down and save.  I don't have a save in my action; just the installation of the watermark.  some how the action worked find a few weeks ago; what am i doing wrong now?   I am using CS4 Extended.
    Tks!!

    Thank you!
    Here are my actions:
    Make text layer
    select layer "background"
    align current layer
    align current layer
    Select layer "@myname"
    Set current layer
    What really is disturbing, is this worked just fine a few weeks ago!  I didn't get the images to come up waiting for me to save them, they just automatically went directly into the folder i directed them to in the batch processing.

  • 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?

  • How to batch process multiple layers to jpegs

    I have over 500 layers of different texts over a simple background image. I need to move through each one of these layers, making only one and the background visible, then doing the same for the next, and saving each out as a separate .jpeg. I know how to batch process the jpegs giving each a different filename, but how do I move through the layers?
    Thanks.

    Hi, Paul--
    You were correct. The normal script didn't work at all. But I'm a bit confused about how to use Layer Saver. I currently have all the texts in groups, labelled 1-50, 51-100, etc. What settings should I use to get it to work?
    Thanks
    J.

  • How to use the same (selection) paths in multiple images for batch processing?

    I have a whole bunch of photos I need to batch process, but, when creating an action for this, I stumbled upon the problem that the paths I selected with the pen tool, and saved under the "Paths" tab need to be in every image for to be used in the action. I did try to solve it for some time, but couldn't figure out. Any ideas?
    Many Thanks
    Carlos

    Batch processing usually involves using actions you have recorded.  In Action you can insert Path that can be used during processing documents.  Path have some size so you may want to only process document that have the same size.  Look in the Actions Palette fly-out menu for insert path.  It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..

  • Batch processing with an image overlay

    Is it possible to do batch processing with an image overlay in FW CS4?
    I'm trying to resize several hundred images and place rounded corners on them.
    If this cannot be done in FW, does anyone know of another program that could accomplish this?

    Hi Marje,
    It's possible to include both resizing and image overlay in a custom Fireworks command that can be used in batch processing.  To get started, you could check out this tutorial that deals with the first step.
    That article describes how to perform image resize and overlay (in that case, a watermark), and then how to record the steps and turn them into a custom command that can be later used in batch processing.
    Once you saved the custom command, click File >> Batch Process, and follow the steps below:
    In the first window, select the images you want to process.
    On the next screen, open the Commands dropdown menu and select the custom command you created (it'll probably be on the bottom of the list), and click the Add button to include it in the batch process list.
    Finally, on the next screen select the location of the processed files, and optionally save the batch script for later use.
    Good luck!

Maybe you are looking for

  • Wifi not connecting properly?

    My internet provider recently installed a new modem and ever since I am having problems connecting my MacBook Air to the new wifi network. it sometimes will not find the network at all, or it can take minutes to do so. This was never an issue on the

  • IDVD won't 'Save as...'

    I've just upgraded to iDVD 7.0.1 and my main project now won't 'Save as...' or 'Archive...'. If I select either of those items from the menu, the program instantly crashes, without even a Crash Report Form to reply to Apple. Oddly, I can 'Save', so t

  • :system.trigger_node_selected

    How do I programmatically set the :SYSTEM.TRIGGER NODE SELECTED to true after a right mouse click on the node? I've tried the following: Ftree.Set_Tree_Selection(htree, :SYSTEM.RIGHT_MOUSE_TRIGGER_NODE, Ftree.SELECT_ON); This will highlight the node

  • Help with Option 3 please

    A week ago I was on Option 1 but due to heavy use my speed was reduced to 15.7k/sec !.I was advised to upgrade to Option 3 which I promptly did and that was done on the 29th(last week). My speed though is still 15k/sec and I cannot watch any streamin

  • Place photo in shape

    I would like to place a photo inside a shape in a pages document. When I drag the photo to the shape the shape moves out of the way! Can anyone help me? Thank you. Ian. Macbook   Mac OS X (10.4.9)