Resizing, renaming images...

Okay, maybe Java isnt the solution for this, but I figured I'd check it out.
I'ma photogenic person, I love my digital camera to death but I have a problem... When I take the images off my camera they're like 2200px by 1800px or something to that effect, way to large. So I immediately open them in photoshop, resize them, and save/rename them. It's rather tedious. So I'm looking to write an application, preferably in java, that I will enter in a directory (c:\dir\blah\blah) and it takes all the images in there and resizes them to say 600x400px and bumps the quality down from 10 to 7 (photoshop talk there, heh) then saves them.
Is Java best for this situation, if so, can anyone push me into the right direction?

It can be done with java.
I wrote a hobby application to generate thumb-views (and extract exif data) into a separate directory. It is written in Java including the thumb-views' resizing from the original images. I used code snippets (for resizing) and an exif package found in the internet - see the comment in the code.
If I had your address, I could mail the whole stuff to you.
Beware however the spammers' e-mail-sniffing bots!
As said it was a hobby project. But you do not need to reinvent the wheel.
Image Magic(k) has ready-made tools (convert.exe) for this purpose, you only need to write some launcher script. Or some image viewers could provide a GUI interface to this batch-like activity, maybe Irfanview too.
http://www.imagemagick.org/script/index.php
http://www.irfanview.com/
package hu.bij.thwutil;
//http://blog.cyberjos.idv.tw/space/Esaily+scale+image+in+Java
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class SImage
  public static final String    JPEG = "jpg";
  public static final String    PNG = "png";
  private int                   srcHeight = 0;
  private int                   srcWidth = 0;
  private int                   height = 0;
  private int                   width = 0;
  private double                scale = 0.0;
  private boolean               resized = false;
  private BufferedImage         bimage;
  public SImage( String filename )  throws Exception
    this( filename, 1.0 );
  public SImage( BufferedImage aimage, double scale ) throws Exception
    bimage = aimage;
    srcHeight = bimage.getHeight();
    srcWidth = bimage.getWidth();
    setScale( scale );
  public SImage( String filename, double scale ) throws Exception
    this(ImageIO.read(new File( filename)),scale);
  public void write(String filename, String format ) throws Exception
     write(new File(filename),format);
  public void write( File output, String format ) throws Exception
    BufferedImage       bimage2 = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
    Graphics2D          g2d = ( Graphics2D ) bimage2.getGraphics();
    if ( resized )
      g2d.scale( ( double ) width / srcWidth, ( double ) height / srcHeight );
    else
      g2d.scale( scale, scale );
    g2d.drawImage( bimage, 0, 0, new JFrame() );
    ImageIO.write( bimage2, format, output );
  public void resize( int width, int height )
    if ( width < 1 )
      width = 1;
    if ( height < 1 )
      height = 1;
    this.width = width;
    this.height = height;
    resized = true;
  public boolean isResized()
    return resized;
  public double getScale()
    if ( resized )
      return 0.0;
    return scale;
  public void setScale( double scale )
    if ( scale < 0.01 )
      scale = 0.01;
    else if ( scale > 16.0 )
      scale = 16.0;
    this.scale = scale;
    height = ( int ) ( srcHeight * scale );
    width = ( int ) ( srcWidth * scale );
    resized = false;
  public int getHeight()
    return height;
  public int getWidth()
    return width;
  public int getSrcHeight()
    return srcHeight;
  public int getSrcWidth()
    return srcWidth;
  public static void main( String args[] ) throws Exception
    if ( args.length != 3 )
      System.out.println( "Usage: java ImageScale [src] [dest] [rate]" );
      System.exit( 0 );
    SImage      image = new SImage( args[ 0 ], Double.parseDouble( args[ 2 ] ) );
    image.write( args[ 1 ], SImage.JPEG );
    image.setScale( 0.5 );
    image.write( "1" + args[ 1 ], SImage.PNG );
    image.resize( image.getWidth() + 300, image.getHeight() + 100 );
    image.write( "2" + args[ 1 ], SImage.JPEG );
}

Similar Messages

  • Batch Resize, Rename & Watermark

    Hi, I was just wondering if you can batch resize, rename & watermark with Aperture? If not then can anyone recommend a piece of software that does have these features?

    "Exporting versions" in Aperture is the 'batch resize' as well as the 'batch rename' function all in one. When you choose to export a batch of images, a dialog box will appear with naming options as well as sizing options (as well as tons of other options).
    I have changed my presets to reflect the size i need on export, then i choose that preset from the export dialog box when it's time to export. I'm pretty sure you can export with a watermark, although I'm not sure.
    I have used TONS of different options to rename and resize, not to mention editing. Aperture does it all. Watch the tutorials, once you get a handle how Aperture works, you will not need anything else.

  • Using Javascript & Actions to resize an image and add the filename as text

    Hello,
    I am currently working on a way to take an image, resize it and add exactly what is in it's file name (before extension) as a text layer. I have succeded in this BUT am having issues with file names that require more than one line of text.
    I need the text to align to the bottom of the image & the script or action must then resize the image so that the text does not overlap.
    Any ideas on how this can be done?
    At the moment I am using:
    -"Fit Image.jsx" to resize my image to a specific size (This was included in the Photoshop CS5 scripts)
    - A script to add the file name without extension and place the file name at a specific position.
    AdFileName.jsx
    if ( documents.length > 0 )
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    try
      var docRef = activeDocument;
      // Now create a text layer at the front
      var myLayerRef = docRef.artLayers.add();
      myLayerRef.kind = LayerKind.TEXT;
      myLayerRef.name = "Filename";
      var myTextRef = myLayerRef.textItem;
      // strip the extension off
      var fileNameNoExtension = docRef.name;
      fileNameNoExtension = fileNameNoExtension.split( "." );
      if ( fileNameNoExtension.length > 1 ) {
       fileNameNoExtension.length--;
      fileNameNoExtension = fileNameNoExtension.join(".");
      myTextRef.contents = fileNameNoExtension;
      // off set the text to be in the middle
      myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
      myTextRef.size = 12;
            myTextRef.font="Arial-BoldMT"
            //set position of text
            myTextRef.justification = Justification.CENTER;
            myTextRef.kind = TextType.PARAGRAPHTEXT;
            myTextRef.width= docRef.width;
            myTextRef.height= docRef.height/ 2;
            myTextRef.position= [0, docRef.height * 0.88];
    catch( e )
      // An error occurred. Restore ruler units, then propagate the error back
      // to the user
      preferences.rulerUnits = originalRulerUnits;
      throw e;
    // Everything went Ok. Restore ruler units
    preferences.rulerUnits = originalRulerUnits;
    else
    alert( "You must have a document open to add the filename!" );
    Can the position be changed to allow more rows of text but keep it aligned with the bottom of the layer?
    How can I script in a way to make the image resize based on the amount of text lines?
    Any help would be greatly appreciated.

    You can add a text layer any where the only thing you need to worry about is the size of the font you use.  You can normally calculate a font size by saving the images resoltuion and then setting its resolution to 72 DPI calculate a font size basied of the images pixel width and the number of characters you want in a line. After adding the text layer you can restore the image to its original resolution and align the text layer by making a selection and alignint the text layer to the selection.  There are nine posibilites like the positions in the selection you can align to like a tick tack toe board. You need to use a script to add the text layer because your retrieving the filename.  The positioning of the text layer could be done easily in an action the would use the scriot to add a text layer the do a select all  the align the added text layer to the selection.
    About your script don't make text paragraph just add new line characters to make a multi line text layer So it can be positioned easily
    I do just that with my stampexif action.  The action uses my stampexif Photoshop java script to add a multi line text layer containing some formatted EXIF data then the action centers the text layer and add a layer style to it. Link http://www.mouseprints.net/old/dpr/StampExif.jsx Example

  • Photoshop CC: Have a template that I moved image into.  Image is too small.  How do I resize the image while in the template?  Or must I go to original image file and resize there again and again until I get the right fit?

    I have a template that I am able to plug different pictures into at different times.  The problem is that when I plug an image into that template, I find that the image is either too big or too small.  Is there a way to plug the image into the template and resize the image (and not the template itself) OR will I have to go to the file with the original image and resize it there and then try to plug it in to the template to see if it fits------and if it does not fit, go back to the original file with the image and resize it again and see if that fits---and so on and so on...........?  I have tried the" image size" option but it's hit or miss------mostly miss!
    Thanks!

    Read up on Smart Objects. It looks like you have no idea as to how to create and use them.
    Jut create a Smart Object from the layer containing whatever it image it is that you are "plugging into your template".  But you do need to learn the application at its most basic levels.
    Photoshop is a professional level application that makes no apologies for its very long and steep learning curve.  You cannot learn Photoshop in a forum, one question at a time.
    Or is it possible that you don't even have Photoshop proper but the stripped-down Photoshop Elements?"
    If the latter is the case, you're in the wrong forum.  This is not the Elements forum.
    Here's the link to the forum you would want if you're working in Elements.:
    https://forums.adobe.com/community/photoshop_elements/content
    If you do have Photoshop proper, please provide the exact version number of that application and of your OS.
    (edited for clarification)

  • Help needed in Drag and Drop and  resizing of image icons

    Hi all,
    I'm doing a project on Drag and Drop and resizing of image icons.
    There is one DragContainer in which i have loaded the image icons and i want to drop these image icons on to the DropContainer.
    After Dropping these icons on to the DropContainer i need to resize them.
    I have used the Rectangle object in resizing.
    The problem now i'm facing is when i drag, drop and resize an image icon and when i try to drag, drop a second image icon the first image icon gets erased.
    can any one help me in fixing this error.
    if u want i can provide the source code.
    thanks in advance
    murali

    the major restrictions in its implemented only in
    jdk1.1.Why!

  • I need some help resizing my images on PS6. I am using a mac and have been trying to resize with same resolution and constaining proportions but for some reaseon the smaller resized image appears pizelated.

    I need some help resizing my images on PS6. I am using a mac and have been trying to resize with same resolution and constaining proportions but for some reaseon the smaller resized image appears pizelated. Heres an image of before and after. The first image I use is a JPG 72dpi 1500px x1500px and I want to downsize it to 600x600px same res, but it keeps pixelating, this has never happened before. Any suggestions, thoughts?
    thanks!

    I wouldn't say pixelated; more like blurry.
    Like ConnectedCreative said, what steps are you using? Are you using "bicubic sharper" when resizing down?

  • How do I resize an image in Photoshop CS2?

    Hi! I'm trying to resize an image in Photoshop Cs2 with OUT making it grainy or blurred. Please help!? I know there's some key you can hold down while dragging with the mouse but eh I forgot it! o_0 please help!

    Jody...
    If you have a vector version of the logo, the smartest thing is to resize it as vectors to the size you want, and
    then
    rasterize it.
    Case in point:
    I was trying to make a 16px × 16px favicon for my blogspot site, and the only way I could get the details to appear nice and clean was to create the entire thing from shape layers, transform them all in one go to fit inside a 16px × 16px box I defined using guidelines, and THEN rasterize it using the Save For Web dialogue.

  • How do I resize an image in Lightroom?

    Hi everyone, was wondering if someone can help me as am trying to resize and image in lightroom and cannot find where to do it.. please help. thanks alexandra

    The Alamy upsizing is nonsense but you can actually use Lightroom export. You only have to use differnet numbers (presets) for different aspect ratios. These are the rough numbers for the aspect ratios I use:
    Assuming they want 16x2^20 (16.777.216) pixels rather than 16x10^6 (16.000.000) pixels, the image dimension to upsize with LR are the following:
    Aspect ratio 2:3 (portrait or landscape)
    ~ 5017 x 5017 pixels
    Aspect ratio 1:1 (square)
    ~ 4096 x 4096 pixels
    Aspect ratio 16:9 (portrait or landscape)
    ~ 5462 x 5462 pixels
    Aspect ratio 4:3 (portrait or landscape)
    ~ 4730 x 4730 pixels
    You can store those in presets, use sort to sort the images by aspect ratio and export one set after the other with different presets.

  • Automated Resizing of Images in Photoshop Elements 9

    I recently upgraded my wife's Photoshop Elements from version 6 to version 9.  However, there is one feature from version 6 that seems to not work in version 9.  When she drags an image into a blank template (of any size), the image drags in to the template in the full size.  So if the images are three times larger than the template, she has to resize every image after she drags them in which is a pain for her.  Previously in PSE6, when she dragged the image into the blank template, the program would automatically resize the image to fit within the window.  Then she could resize the iamge if she needed to.  It seems that there should be a setting for this, but I am coming up with nothing.  Anybody know of a solution to this?

    You didn't say if your on mac or windows, so you may not be familar
    with the elements organizer. The following workaround works on windows pse9,
    if your on a mac it may also.
    1. In the elements organizer, select (highlight) the photos you want to use.
        (don't open the photos into the elements editor, just select them)
    2. Back in the elements editor, with the project bin open, choose
       Show Files Selected in the Organizer.
    3. When you drag the photos from the project bin into your document, they should resize
       similar to pse6.
       If they are still to big, step back one step in the undo history panel from Transform the Frame to Place.
    MTSTUNER

  • How can I resize an image in Preview?

    There has been lots of discussion about Preview but non really answers my question. If I resize an image and duplicate it the duplicate over rides the settings of the original - so now I have 2 images the same size which is not what I want. I want the new image smaller but to keep the original the same size as before resizing. Versions seem to do the same thing, and as far as I can make out so does export. I know you can revert one of the duplicate images to get it back to the original size but it is a rather convoluted process.
    I know there are very clever people here so perhaps one of you can give me a work flow to do what I require. Thanks in advance.

    Of course, you can save some steps by duplicating the original file first, and then resize the copy.
    rolando

  • How do you resize a image/picture and save it?

    Hello, I know how to resize a image. But how do I save a new image/pictures has Jpeg with new size properties?

    Use File>Save As or File>Save for web. Either of these will create a new document as long as the name is different or is in another folder.

  • Moving and renaming image files

    I want to move & rename image files to folders on the hard drive by dragging and dropping them into my application. I read about the problem with renameTo() method with windows. Is this possible to do in java? I heard about a method in which you read,write and delete the old file? How do I go about making this happen?

    Well, what happens if you create the folder C:/Test/testfile1.txt ?
    Or alternatively remove the part that says "testfile1.txt" from the directory path in your program.
    Or alternatively call dir.mkdirs() before trying to rename.
    What I am getting at is that when you create a file with the constructornew File(dir,newdest.getName())the parameter dir is treated as a directory no matter what its name is. If its name is "C:/Test/testfile1.txt," the name of the new file will be "C:/Test/testfile1.txt/name_of_newdest"where name_of_newdest is the name of the "newdest" file. This might not be what you wanted

  • How do I resize an image within a drop zone (not the drop zone itself) in motion 5?

    How do I resize an image within a drop zone (not the drop zone itself) in motion 5?

    I think others would be able to help if you describe a little more why you'd like to do this. Given that drop zones are a way of passing images into Motion that you want to manipulate, resizing a drop zone is the equivalent of resizing the image.
    If you're having a problem with an image from Final Cut being too big or too small, select the Drop Zone in the inspector and make sure the Fit parameter is set to 'Fit' - 'Center' will result in images dropped not being scaled to fit the Drop Zone. 'Stretch' will force the dropped image to fill the space defined by the drop zone,
    If the image is already cropped and scaled up in Final Cut Pro, that is the information that Motion gets - you can't scale down the image to see more of the edges that have been cropped off.
    If you want more than one copy of the image passed via the drop zone, use Make Clone Layer from the Object menu.

  • Resized & resampled image problems in Elements 5.0 on xp

    I'm having trouble with resize & resample images (trying to make them much smaller) so I can place multiple images onto a PDFpage at predetermined individual specific physical sizes thereby avoiding resizing the images within the PDF document, of which I understand is a NoNo for getting it commercially printed.  When I resize & resample an image and set the physical dimensions of the image it prints as a test print to the size I have set/want. The problem arises after I have saved the image & then try to insert it into my document. The saved image file when inserted is still or very close to the same physical size as before I resized & resampled it. - So what am I not doing or doing wrong. I have checked the file size in Windows Explorer and the actual file size is only a fraction of what the original is. The image has been reduced from 3200KB to 109KB, confirming I have at least reduced something within the file, just not what I wanted to. When I reopen the file in Elements and print it it is still the size I want, so why isn't it the right size when I insert it into a document. I have read the help files and don't understand what I am doing wrong, Please help.

    Hi,
    I suspect that the resolution of the file is getting changed instead of dimensions. So, the file size is decreasing but the dimensions are remaining the same.
    Please confirm that you are resizing the image as follows:
    1. Open the image
    2. Go to Image -> Resize -> Image Size
    3. Select the option Resample Image
    4. Now provide the new dimensions in Width & Height
    5. Click OK and save the image
    Now try importing on the PDF page.
    Thanks,
    Tarun

  • Problem with photoshop automatically resizing placed images

    Hi,
    I have PS6. I have images that are 144x100 px. When I use file>place ps resizes the image to 108x75. I can't figure out how to make ps quit resizing my pictures. Anybody know?
    Thanks

    When Pasting, Dragging, copying and placing an image Photoshop will copy all of the image being duplicated original pixels to preserve the image pixel quality the image quality.  If the receiving document has a different DPI resolution the image may look a different size in the  receiving documents because of the number of pixels added to the document that has a lower or higher dpi resolution.  If the image is being placed in if the image pixels exceeds the receiving documents canvas size. Photoshop may scale the smart object layer to fit within the canvas that depends on the users Photoshop's preference.  All of the images original pixels are still there in the embedded object.   In my Photoshop Collage Scripts  I always transform all placed images to 100% size  incase Photoshop scaled the placed image.  For you can not get the scale percent Photoshop used.  Once I know I have the image at 100% size I can use the layer bounds to get the actual number of pixels there are in the placed image.  Once I know that I can calculate the scale I need to use to resize the image to fit the area being populated in the collage template.   Once resized I center it into place and mask off any excess image pixels.

Maybe you are looking for