Batch Resize photos Larger than a certain size.

Is there a way to have a script that searches a directory and any image files that are larger than 1000 x 1000 pixels are resized to 500 x 500 pixels and then saved over righting the sources file?
I am asking because our server has over 40,000 photos all over the place and I would like to reduce the space they take on the server.

I don't think that getting the file's length is the best way to determine if the file needs resizing. Especially if the file is in a format that supports compression. I think you would end up either setting the test value too low and open a lot of files that don't need resizing or set too high and miss files that do.
Also using getFiles() without a file mask will get all files and folders in the source folder. You will need to make sure it is an image file before trying to open in Photoshop to resize.
I think the function below would be a better way to determine if the file needs resizing. It tries to get the XMPMetadata to determine width and height. If that fails because the file does not have metadata it gets the size from Bridge.
var file = new File('~/desktop/_SLP7637.jpg');
var resize = needsResizing( file );
var resizeStr = ''
resize? resizeStr = 'needs resizing': resizeStr = 'does not need resizing';
alert(file.fsName+" "+resizeStr);
function needsResizing( file ){
    try{
        loadXMPLibrary();
        var xmpf = new XMPFile( file.fsName, XMPConst.UNKNOWN,
                                   XMPConst.OPEN_FOR_READ );
        var xmp = xmpf.getXMP();
        xmpf.closeFile();
        var dim = xmp.getProperty( XMPConst.NS_EXIF, 'PixelXDimension', XMPConst.STRING)+','+xmp.getProperty( XMPConst.NS_EXIF, 'PixelYDimension', XMPConst.STRING);
        dim = dim.split(',');
        unloadXMPLibrary();
        if(dim=="undefined,undefined"){
            var dim = undefined;
            var res = undefined;
            var bt = new BridgeTalk;
            bt.target = "bridge";
            var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+file.toSource()+");");
            bt.body = myScript;
            bt.onResult = function( inBT ) {myReturnValue(inBT.body); }
            bt.send(10);
            function myReturnValue(str){
                res = str;
                dim = str.split(',');
            function psRemote(file){
                var t= new Thumbnail(file);
                return t.core.quickMetadata.width+','+t.core.quickMetadata.height;
    }catch(e){unloadXMPLibrary();}
    var res = true;
    if(dim[0]<1001&&dim[1]<1001) res = false;
    return res;
function loadXMPLibrary(){
     if ( !ExternalObject.AdobeXMPScript ){
          try{
               ExternalObject.AdobeXMPScript = new ExternalObject
                                                            ('lib:AdobeXMPScript');
          }catch (e){
               alert( ErrStrs.XMPLIB );
               return false;
     return true;
function unloadXMPLibrary(){
   if( ExternalObject.AdobeXMPScript ) {
      try{
         ExternalObject.AdobeXMPScript.unload();
         ExternalObject.AdobeXMPScript = undefined;
      }catch (e){
         alert( ErrStrs.XMPLIB );

Similar Messages

  • I'm trying to make "Stop motion videos"  in Final Cut EXPRESS by using 100's of still photos and setting them to music.  They are coming out blurry if viewed larger than 4x6 in size

    I'm trying to make "Stop motion videos"  in Final Cut EXPRESS by using 100's of still photos and setting them to music.  They are coming out blurry if viewed larger than 4x6 in size.
    I don't understand why this is happening. 

    Quick follow up, since I was on my phone earlier and am back to a real keyboard.
    To access Easy Setup, hit Control Q.
    If you click on the blue discosure triangles, a dropdown menu with about a dozen different presets will be displayed. Select the one you want, (Here, I've selected 720P.)
    Whatever you select for a preset will not be applied until you make a new sequence. (I don't like to have sequences with different properties in the same project so I prefer to make a new project if I change the Easy Setup.)
    Because photo aspect ratios are different than video, I typically put a solid generator of some compatible color on the first track (v1) and put my photos on the track above (v2). Looks better, IMO, than black bars. There are other creative ways to display them. And of course, you could scale them up to fill the frame…but then you probably would have to re-position them.
    Good luck.
    Russ

  • How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?

    How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?  I would like them to open at the size they were previously resized like they used to in previous operating systems.  They currently open at a very small size and the first colum is only a few letters wide necessitating a resize practically every time one wants to use it.  Any help would be appreciated.

    hi Prasanth,
    select werks matnr from ZVSCHDRUN into table it_plant.
    sort it_plant by matnr werks.
    select
            vbeln
            posnr
            matnr
            werks
            erdat
            kbmeng
            vrkme
            from vbap
            into table it_vbap
            for all entries in it_plant
            where matnr = it_plant-matnr and
                  werks = it_plant-werks.
    and again i have to write one more select query for vbup.
    am i right?

  • FSRM reporting quote usage larger than the actual Size

    File server resource manager is reporting quote usage larger than the actual Size or even “Size on Disk”. The only theory I have so far is that the FSRM is counting data in Shadow Copy. Does FSRM count data in Shadow Copy?

    Hi,
    Please check if you turn on the NTFS file system compression functionality or if you compress the files that you own on an NTFS volume. If so, the disk quota that you are charged increases.
    Disk Quota Charges Increase If You Turn On the NTFS Compression Functionality
    http://support.microsoft.com/kb/320686/en-us
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Can I resize photos and reduce JPEG file sizes by using Photpshop Elements?

    Can I resize photos and reduce JPEG file sizes by using Photpshop Elements?

    Go to Image>Resize>image size.
    For purpose of web posting, go to File>save for web.

  • Printing a component that is larger than the paper size

    Hi,
    I am trying to print a component that may be larger than the size of the paper being used. Is there some way to get it to split between pages - ie, if it's larger than the page, it is printed over two or more pages?
    The component in question is a JTextArea. Would it be better to get the text from it and use the graphics drawString rather than the component's paint method?
    The relevant part of the code is below.
    Thanks,
    Helen
         //cast the Graphics object to a Graphics2D object
         Graphics2D g2 = (Graphics2D) g;
         //set the origin to be (0,0)
         g2.translate(format.getImageableX(), format.getImageableY());
         //if double buffering is enabled, disable it before printing
         boolean b = testForDoubleBuffering(c);
         if (b == true){
         disableDoubleBuffering(c);
         //tell the Component to draw itself to the printer
         comp.paint(g2);
         //if double buffering was enabled, reenable it once printing has happened
         if (b == true){
         enableDoubleBuffering(c);
         //return this constant to tell the PrinterJob that the page has been printed
         return Printable.PAGE_EXISTS;

    Hi,
    I am trying to print a component that may be larger
    than the size of the paper being used. Is there some
    way to get it to split between pages - ie, if it's
    larger than the page, it is printed over two or more
    pages?
    The component in question is a JTextArea. Would it be
    better to get the text from it and use the graphics
    drawString rather than the component's paint method?
    The relevant part of the code is below.
    Thanks,
    Helen
         //cast the Graphics object to a Graphics2D object
         Graphics2D g2 = (Graphics2D) g;
         //set the origin to be (0,0)
    g2.translate(format.getImageableX(),
    format.getImageableY());
    //if double buffering is enabled, disable it before
    printing
         boolean b = testForDoubleBuffering(c);
         if (b == true){
         disableDoubleBuffering(c);
         //tell the Component to draw itself to the printer
         comp.paint(g2);
    //if double buffering was enabled, reenable it once
    printing has happened
         if (b == true){
         enableDoubleBuffering(c);
    //return this constant to tell the PrinterJob that
    the page has been printed
         return Printable.PAGE_EXISTS;I should add that this is part of a class that implements Printable. However, it is being called by a Book class with the Book's append() method. It is the Book class that is being printed by the PrintJob:
         Book book = new Book();
         book.append(new PrintableClass(c), format);
         //set the pageable class to be the book, with the user-selected format
         job.setPageable(book);
         //if the user clicks the print button, start the printing process, otherwise cancel the print
         if(job.printDialog()){
         try {
              job.print();
         } catch(PrinterException pe) {
              System.out.println("Error printing: " + pe);
    Thanks,
    Helen

  • Xp_smtp_sendmail file size is larger than allowed max sizer of 65536 bytes

    Hi,
    We have a daily routine which generates a text file and runs xp_smtp_sendmail with the @messagefile argument to use the text file in the body of the email.
    It has always worked fine but recently we have been receiving the following error when trying to run it:
      Error: @messagefile "Drive\Filename.txt" file size is larger then allowed max size of 65536 byte
    Funnily enough the file in question is 66,220 bytes so only just big enough to exceed this limit. The file in question is created from scratch on a daily basis so maybe this limit has always been in place
    and we are now exceeding it. My question is can we increase this limit somewhere and if so where? The SQL Statement I'm running is:
    EXEC master.dbo.xp_smtp_sendmail
    @To = '[email protected]',
    @From =  '[email protected]',
    @messagefile = 'Filepath\Filename.txt',
    @subject='Test please ignore',
    @server='smtp.servername.domain'
    Thanks in advance for any suggestions anyone has!

    what version of sql ser using?? it looks like you are using SQLMail. if you are sql 2005 and baove you can use database mail and use that to send mails
    check for to set up database mail http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/
    change the max file size configuration for database mail https://msdn.microsoft.com/en-us/library/ms186321.asp
    Hope it Helps!!

  • Why are exported photos larger than dragged photos?

    I have a jpg image in my iPhoto '11 (9.2.1) library that shows it is 3.7MB; imported direct from camera, no editing whatsoever.
    If I drag it to my desktop (on a MacBook 13"), then File Info shows the dragged image is [still] 3.7MB with the same dimensions.
    But, if I export from iPhoto to the desktop, as a JPEG with Maximum Quality and Full Size, the exported image on the desktop shows it is 7.5MB with the same dimensions.
    ? Huh?
    What's happening here?
    Can somebody explain how an image can grow?
    (I've replicated this three times with three separate images and it has happened all three times.)

    I can explain and the image isn't growing.
    You need to separate two things in your head. That file is not your Photo. That file is a box containing your Photo.
    The illustration I use is as follows: In my iTunes Library I have a file called 'Let_it_Be_The_Beatles.mp3'. So what is that, exactly? It's not the song. The Beatles never wrote an mp3. They wrote a tune and lyrics. They recorded it and a copy of that recording is stored in the mp3 file. So the file is just a container for the recording. That container is designed in a specific way attuned to the characteristics and requirements of the data. Hence, mp3.
    Similarly, that Jpeg is not your photo, it's a container designed to hold that kind of data.
    iPhoto is all about the data and not about the container. So, iPhoto will manage the photo, edit the photo, add metadata to the Photo but never touch the file. If you choose to export - unless you specifically choose to export the original - iPhoto will export the Photo into a new container - a new file containing the photo.
    (As you've never edited the file, dragging is the same as exporting the original)
    So now you have two files each containing the same Photo.
    The file size is different because your camera applies a Moderate level of compression to the file when it creates it.
    You're exporting at Maximum Quality. That means "minimum compression". So, the export from iPhoto is less compressed than the file from the camera, and therefore is larger.
    Regards
    TD

  • Animation size larger than actual image size after saving as gif?

    Hi,
    I just created an animation (600x600 pixel) and saved it as gif. Everything seems fine except the grainy quality and the fact that it is nearly twice as large as my actual image size (100%) shown on photoshop. I don't mind the grainy quality but the large size is disturbing... Anyone know why or how to fix this problem?
    Any help will be appreciated as it's an anniversary gift and I'm stuck on the last step running out of time . Thanks in advance!
    Angela.

    The 300GB partition is the partition I am booting off of, and the one I was writing about. Disk0s1 is the EFI partition, 210MB. The other Internal hard drive is the core storage physical volume, already mounted, mounted in the image. Recovery HD is the 650MB system recovery partition.
    I rebooted to the recovery partition and used Disk Utility to verify the volume, it said everything checked out alright.
    In disk utility, the top entry has this data
         Name :     Internal Hard Drive     Capacity :     319.21 GB (319,213,174,784 Bytes)
         Type :     Logical Volume Group     Available :     16.8 MB (16,777,216 Bytes)
         Disk Status :     Online     Used :     319.2 GB (319,196,397,568 Bytes)
    However the other entry, right below it has this
         Mount Point :     /     Capacity :     318.88 GB (318,877,626,368 Bytes)
         Format :     Encrypted Logical Partition     Available :     202.18 GB (202,175,160,320 Bytes)
         Owners Enabled :     Yes     Used :     116.7 GB (116,702,466,048 Bytes)
         Number of Folders :     241,519     Number of Files :     1,246,454
    So I guess the reboot fixed my problem, df -h now shows 37% used, but the logical vomume group still shows only 16MB free. Anyways, things seem to be working now.

  • How can i batch resize a pdf  than save from one folder to a bmp in another folder?

    At the moment I can get it to work but it is just using one document name and not the individual file names?

    Not absolutely sure but I think Actions would struggle with this because the files can not be opened but has to be converted.
    Image Processor does not offer bmp, maybe you should check out Image Processor Pro.
    http://www.russellbrown.com/scripts.html
    Or use the regular Image Processor to create tif or psd and then open and save those as bmp …
    Why bmp anyway?

  • Batch Resizing Based On File Size

    I have a lot of very large (400-600Mb) tiff files (from a scanner) that all have different ratios (some square, some 4:3, some extreme panoramic). Is there a way I can batch resize them all to a certain file size? (eg 200Mb)
    I've been looking everywhere but can't find anyone on any forums trying to do the same thing. Strange because i thought it might be quite a common problem.
    Thanks for any help/advice,
    Lewis

    Resizing is very much dependent on Image compression algorithms (or what ever they are called)… My Guess is that this is beyond the 'average' scripter if you wanted to deal with the open file data size then this can be done. If you want to deal with saved file's system sizes you may well be out of luck…

  • Why is menu size so much larger than the files?

    I am somewhat perplexed - I'm making a single-layer dvd and have a simple single screen theme (no animation) - it has one drop zone. The movie has 28 chapters so there are five of them, but so far I've added only one montage of photos to each menu page - it's a "mobile" quality in media browser and ave only 10 - 20 MB, then one song. On average these movie clips are 1:00 to 2:00 min long and the music is cut to that length. So, all told, it's probably less than 110 MB in files - but when I look at the project properties, the menus are 3301 MB!!!
    The movie itself is only 1.1 GB so what is going on?
    It's preventing me from doing the project and I've got no idea why it's making the menu size so much larger than the file sizes?
    Can you please help me figure out what to do?
    Alexa

    The 2 min clips were natively 2 min - I had each one separate and actually converted to media browser in "mobile" size (b/c the drop zone was 4 x 6 in size in the theme). They were tiny - in most cases I was shortening the audio (e.g. the song was 4 minutes and I was setting the loop to only 1:30 b/c that's how long the video clip was on the menu).
    BUT, to resolve the question (I always like to post the answer) - I ended up duplicating the project to try to reimport the video. It was a fresh iDVD project and I happened to click on the project tree of screens - and, lo and behold, the ENTIRE menu was duplicated for some reason (and the movie, actually). I went back to the original and it was the same! I have no idea how that would happen do you? It only had one main menu screen - and then an entire duplicate menu - which I wouldn't even know how to access if I didn't see it in the project menu tree?
    The only think of is that at one point I added a title menu link to the scene selection - it gave me a warning that my menu was more than 12 minutes, did I want to fix or ignore and fix later - which confused me b/c it was under 12 min, then but I clicked ignore. Does that create an alternate title menu and send people back to something else?
    Anyway, I deleted the entire extra scene selection menus (5 of them) and it was back to under 4 GB.
    So, I was able to burn, but still wondering about creating the "title menu" link on scene selections? It drives me crazy that it doesn't automatically do that so I like to add "main menu" links.
    Thanks for your help!
    Alexa

  • How to display graphics larger than canvas size?

    How do I display graphics larger than canvas size in Java AWT?
    I tried setting the canvas size() to a value larger than my monitor size, and then adding scroll bars to the canvas, but the scroll bars and the canvas won't go beyond the monitor size in pixels, which is only 800, so the large graphic I try to display gets cut off at the bottom.
    How can I overcome this problem? Has anybody encounter a similar dilemma before?

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class AWTSizing
        public static void main(String[] args)
            LargeCanvas canvas = new LargeCanvas();
            ScrollPane scrollPane = new ScrollPane();
            scrollPane.add(canvas);
            Frame f = new Frame();
            f.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
            f.add(scrollPane);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class LargeCanvas extends Canvas
        int w, h;
        final int PAD = 10;
        Rectangle r1, r2, r3;
        Rectangle[] rects;
        boolean firstTime;
        public LargeCanvas()
            w = 360;
            h = 360;
            firstTime = true;
        public void paint(Graphics g)
            super.paint(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(firstTime)
                initShapes();
            g2.setPaint(Color.red);
            g2.draw(r1);
            g2.draw(r2);
            g2.draw(r3);
        private void initShapes()
            r1 = new Rectangle(w/4, h/4, w/2, h*3/4);
            r2 = new Rectangle(w/2, h/2, w/2, h/2);
            r3 = new Rectangle(w*5/8, h/6, w*3/5, h*2/3);
            rects = new Rectangle[] { r1, r2, r3 };
            firstTime = false;
            invalidate();
            getScrollPane().validate();
        private ScrollPane getScrollPane()
            ScrollPane scrollPane = null;
            Component c = this;
            while((c = c.getParent()) != null)
                if(c instanceof ScrollPane)
                    scrollPane = (ScrollPane)c;
                    break;
            return scrollPane;
        public Dimension getPreferredSize()
            Dimension d = new Dimension(w, h);
            if(rects == null)                   // before calling initShapes
                return d;
            Rectangle r;
            for(int j = 0; j < rects.length; j++)
                r = rects[j];
                if(r.x + r.width + PAD > w)
                    d.width += r.x + r.width + PAD - w;
                if(r.y + r.height + PAD > h)
                    d.height += r.y + r.height + PAD - h;
            return d;
    }

  • Batch resizing of photos in either Bridge of PS?

    Hi,
    I am wondering if anyone can advise or assit me?
    I have a number of photogrpahs (188) that I need to batch resize (reduce by 50%), is there a way I can do this en mass, either in Bridge or PS so i dont have to open each one indivdually?
    thanks for your help
    Giles

    You can batch resize photos with Preview.app
    Batch Resize Images on Mac with preview:
    http://osxdaily.com/2009/12/16/batch-resize-images-on-mac-with-preview/

  • Custom Icons Disappear in Cover Flow Above Certain Size

    I've been trying to create custom icons for certain folders and I've been having no luck when viewing them in cover flow.
    I've downloaded a PNG file, 512x512 pixels. Open it in Preview, copy to the clipboard, do a 'get info' on the folder I wish to change the icon of, click the little icon, hit paste, and it appears correctly in the preview and in the finder Icons view, as well as on my desktop or whatever. However, if I turn on cover flow and drag the size of cover flow to larger than a certain point, the custom image disappears and all I get is a blank spot. It's as if the 256 pixel icon is being created but the 512 pixel image is being left blank.
    I do not know if this happened in 10.5.1, as I hadn't tried until after installing the 10.5.2 combo update.
    In the following picture, you can see 1: bottom right, a preview of the png file itself as it appears, correctly, in cover flow, 2: top right, the icon working correctly on the desktop and in the get info window, and 3: left: the cover flow view of the computer showing a bit gaping void where the custom icon should reside.
    !http://www.ece.ualberta.ca/~tomlinso/argh.jpg!
    Any ideas? Thanks in advance!

    This does NOT happen if I use an existing, working icon (say, put the Applications folder's icon onto my hard drive.) It seems to be an issue with custom icons only, not just changing the icon for something.

Maybe you are looking for