Simple Resizing Script - Hopefully better eyes will prevail

     I'm working on a simple resizing script to incrementally resize an image in 5% steps up to the set limits as defined by the variables; newImageHeight & newImageWidth.   I'm currently running this script in Photoshop CS4 on an Intel Mac.
     The script works fine for horizontal format images but vertical images scale incrementally in significantly larger steps than 5% and the final output is well above the limit set by the variable "newImageHeight".
     I'm sure it's something simple that I've just overlooked.  Any help would be most appreciated.
TIA
#target photoshop
//  Sets Adobe Photoshop to use pixels and display no dialogs.
app.preferences.rulerUnits = Units.PIXELS;
var doc = app.activeDocument;
var imageFormat;
var newImageHeight = 4000;  //  Sets the new image height to 4000 pixels.
var newImageWidth = 2880;  //  Sets the new image width to 2880 pixels.
if (doc.height.value > doc.width.value){  //  Determines whether the image is vertical or horizontal in format.
     imageFormat = 1;
     }else{
     imageFormat = 2;
if (imageFormat == 1) {
     alert("Re-Scale Portrait Format");
     while (doc.height.value < (newImageHeight * 0.923550372529964)){
          alert(doc.height.value);
          doc.resizeImage (doc.height * 1.05), ResampleMethod.BICUBIC;
     alert(doc.height.value);          
     doc.resizeImage (doc.height * (1 / (doc.height / newImageHeight))), ResampleMethod.BICUBIC;
     }else{
          alert("Re-Scale Landscape Format");
          while (doc.width.value < (newImageWidth * 0.923550372529964)){
          alert(doc.width.value);
          doc.resizeImage (doc.width * 1.05), ResampleMethod.BICUBIC;
     alert(doc.width.value);     
     doc.resizeImage (doc.width * (1 / (doc.width.value / newImageWidth))), ResampleMethod.BICUBIC;
//  EOF

Check resizeImage out the Object Model Viewer in ESTK.
Document.resizeImage (width: UnitValue , height: UnitValue , resolution: number , resampleMethod: ResampleMethod )
So I think the line
          doc.resizeImage (doc.height * 1.05), ResampleMethod.BICUBIC;
should rather be
          doc.resizeImage (doc.width * 1.05, undefined, undefined, ResampleMethod.BICUBIC);
or
          doc.resizeImage (undefined, doc.height * 1.05, undefined, ResampleMethod.BICUBIC);
What is the Script supposed to achieve anyway?
It’s not based on the obsolete concept of incremental resizing for better results, is it?

Similar Messages

  • My last effort to stay with verizon, hopefully a rep will see this and respond

    I would like to start off by saying that between my self and my father we have been with verizon since he bought an analog cell phone in 1998. But that should not matter because all customers should be treated the same. I will explain my recent issue below.
    This past week a family member who was on my account decided to up and leave verizon and got his own account with T Mobile, who in my area has very good coverage. This is based on actual people who use T Mobile, not looking at a coverage map. He basically stuck me with his line and a $190 ETF. I fully understand that i am responsible for that fee and I'm not arguing that. However this all ties in together with my next part of the story.
    Also, in the middle of all this we have been looking at ways to lower the bill. Currently the bill was around $200 sometimes less sometimes as high as $220. that was for 3 phones and only 2GB of data! only 1 line is under contract . the other 2 have been month to month for probably 2 years. I was unsuccessful at lowering the bill with out having to sacrifice, such as removing insurance, etc. So i explore other carriers. AT&T for 10GB of data, yes 10 GB of data, thats 5 times as much, comes out to 145 a month (100 for data 15 for each device. Compare that to verizon over 200 for only 2GB? thats incredible over $55 a month savings plus 5 times as much data usage. with my 22% off discount from the 100 data id save another $20 so now I'm at $125. with verizon i only get the discount from the data package as well. so $50 ends up being about $40 . not a real savings there .
    current promo - will give me $100 for every line that i open or port over to ATT
    Next stop is T Mobile, unlimited everything for 3 lines is $90 a month for 500 mb of LTE data per line.  if i upgrade that to 2.5 GB per line of LTE data the price is $120 total. and theres no overages after 2.5 GB they only throttle the speed down. for $150 a month i can get unlimited LTE for all 3 lines. but for my case i would only need the 2.5 gb of LTE for 1 line. which puts me at $100 a month and never will have overages. and i can upgrade or downgrade the data on the other lines for only $10 more a month. not a bad deal. I'm between $90-150 depending on how much high speed i want, will never have overages and can change the plan at any time to get more high speed. this works great if I'm taking a trip and will use more data i know i won't have overages. my discount here would be 15% off the entire bill so 110 ends up being 93.50
    current promo - will pay my ETF
    so here are my options -
    att is $125 a month for 10 GB which i will never never never go over.
    t mobile $93.50 a month for unlimited everything and 2.5gb LTE and for only $10 more i can have unlimited LTE
    verizon $200 for 2gb of LTE
    not to mention prepaid carriers .. straight talk, net10 the list goes on.unlimited for $45. all of which have great service in the philly/southjersey area and use the main carriers service anyway.
    before going any further i will say i have 3 unlocked phones that i can use so I'm not factoring in cost of the device. please do not try to justify using one carrier over the other because of the different ways they finance the device.  the device costs are the same at all carriers so that wouldn't change. only thing that changes is how much to put down or pay per month. iphone is always 650, 750, 850 no matter what.
    so now lets put these 2 problems together. I call customer care to see options for canceling the line that the family member stuck me with. Its $190 to cancel. i admit i am responsible for it and explain that i can not afford that fee and if i have to pay that then i will be switching to ATT or t mobile. both who will give me month for switching (tmobile pays the ETF and att will credit me $100 per line so $300 total)
    the rep immediately says i can transfer the contract date to one of the lines with no contract. . I tell him that is a nice offer however those 2 lines have been out of contract for 2 years. and when i want to upgrade them i dont want to be stuck with the upgrade date. i also explained the only phone is used very little for work purposes and i will never upgrade or put a contract on that line. he understands and advises me that that is the only option to cancel a line with no ETF.i move on to my bill. i ask him what can be done about it. i asked about the loyalty plans. he advises me that for my main line i can have $60 loyalty plan which is 2gb data and unlimited talk/text with $15 overage per GB. however theres always a catch. i have to sign a 1 year agreement, i can not thether the data, i can NOT use my discount with a loyalty plan . for the other line i do not use much the only option is 30 minutes no text no data for $15 a month or $45 for unlimited talk/text and 500mb of data and $15 overage for every 250 MB which is crazy . I'm better off just taking 2 of the $60 options. but again i must sign a 1 year agreement, no thether, crazy overage fees and no discount.  so now i end up having 2 lines that are out of contract put onto a contract. 1 of which i can not upgrade until the date of the contract that they switched over. so after 2 years of paying subsidized prices and not having a contract, the only way to get a better price plan is to sign a contact (which was never offered before when you sign a contract) then they dictate how i can use my data by saying i can't thether, plus have overages and no discount.  2gb is borderline. yes i can stay under if I'm constantly checking my data count and only use the phone when i need to. not for fun.
    needless to say i told the rep i would on consider and call back. today i call back 2 times to get more information and see if theres a different type of loyalty plan. one time i get the run around. the next time I'm on "hold", but the theres no hold music, etc is just quiet..... so i hung up after 20 mins.
    At this point the only way I'm considering staying with verizon is if i can get a good price plan.
    hopefully a rep will see this and respond. my billing cycle ends the 6th and this is the last weekend i have to make the switch before I'm billed another $200 for 2gb of data.

    Unfortunately since you didn't mark your post as a question, the VZW reps that roam this community won't see it nor will they respond to it.
    Signed,
    Just another customer

  • A simple "sudo" script

    Hi, I wrote a simple "sudo" script for people who prefer to use su rather than sudo.
    #!/bin/bash
    while [ -n "$1" ]
    do
    command="${command} $1"
    shift
    done
    su -c "$command"
    Usage:
    put it in /usr/sbin, then for example, do
    sudo pacman -Sy
    Password:
    enter root password
    Advantages:
    for those who don't like sudo, this sudo script is convenient for one line commands
    simple bash completion
    Hope you find it useful

    Xilon wrote:Couldn't you just do:
    alias sudo='su -c'
    That would require you to manually put ' ' around your command, and miss bash completion.
    mucknert wrote:Uh. sudo allows a much finer selection of rights. You can say what user or group is allowed to execute with its own password (or no password at all) instead of the root pw. That's a lot more than your script does and those are good reasons, too. Read up on sudo one day. You will be suprised.
    Thanks for your suggestion, I just had a quick read through sudo and sudoers. This is some stuff I found:
    The time stamp issue was never a big one, and you can configure the time or disable it. I find sudo -k useful too.
    I thought sudo might add security risk if the user password was compromised, but you can configure sudo to ask for the root password. However, this would defeat the purpose for those who disable root.
    I also have a questions: if you want to do access control, why would you prefer sudo over simple file permissions? Or is sudo primarily used as a finer access control scheme?
    Again, thanks for your advice, I really appreciate it. Please point out anything wrong with my questions. The manual was pretty long, so I'm bound to miss something.

  • Help with simple Automator script

    I have a simple Automator script for updating a specified folder with files from another folder. It consists of only two actions:
    1. Get Folder Contents (from the folder I drop on the Automator executable).
    2. Copy Finder Items.
    I left the option "replace existing files" unchecked because there's no point in replacing a bunch of files that already exist (we're talking about 4000-5000 files in the source folder).  I assumed that meant to ignore any existing files but, on the contrary, I found out that the script is copying duplicates of all the existing files -- making my target folder about 9000 files strong!
    How do I get a command into the middle of this script to restrict the Copy Finder Items command to files that do not already exist in the target folder? (It would be even nicer if it could check for files that are older than the files being copied and actually replace (only) those as well.)
    Any ideas?

    If you need the Terminal window to stay open, then you're looking at scripting Terminal. You can do this with Automator's run applescript action, or you can just use Script Editor (in Applications > AppleScript). Either way you will need to save the workflow/script as an application and drag it to your Login Items (in System Preferences > Accounts).
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "Terminal"
    activate
    set commands to "cd /Users/lenny/ventrilo/ 
    /Users/lenny/ventrilo/ventrilo_srv"
    do script commands in front window
    end tell</pre>
    PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB   Mac OS X (10.4.3)  

  • Solaris 11 - run a simple BASH script on computer startup

    I need to have a simple BASH script run on my Solaris 11 machine automatically whenever the computer (re)starts. It should be run with root permissions and after the computer has fully booted. What is the easiest way to do that?
    Thank you
    Dusan

    Hi user9368043
    Yes, that should be right, and be intended this way.
    See /etc/rc3.d/README and the following part from smf(5):
    Legacy Startup Scripts
    Startup programs in the /etc/rc?.d directories are executed
    as part of the corresponding run-level milestone:
    /etc/rcS.d milestone/single-user:default
    /etc/rc2.d milestone/multi-user:default
    /etc/rc3.d milestone/multi-user-server:default
    Your question concerning upgrading to Solaris 11.1:
    In the Gnome menus, you should look for (and start)
    System --> Administration --> Update Manager
    Let it do its work. It will give you a new boot environment, containing Solaris 11.1. Possibly, you have to perform upgrading twice. With "beadm activate", see beadm(1M), you can go back to Solaris 11.0 whenever you want.
    "Local" parts of your zfs root pool, like /usr/local, home directories, /root, and so on, should be in separated file systems, and be mounted outside the root pool before upgrading. They are availlable then from any boot environment, and will not be duplicated. See more in zfs(1M), zpool(1M).
    I strongly recommend upgrading. Solaris 11.1 is great.

  • Simple UCCX script for IVR,Welcome message then press 1 and press 2

    Dear Experts;
    I have uccx 10.5.
    I want to write a simple IVR script as below.
    Step-1- Welcome message.with press 1 for Sales and Press 2 for Marketing
    step-2   User Press 1 then transfer the call to Sales Skill Group.
    Step-3  User press 2 then transfer the call to  Marketing Skill group.
    My doubt is how to accept when user press 1 and match the value and then transfer the call to that skill group.
    Really appreciate any link or script for this.
    Regards
    Debashis

    Dear Martyn;
    Thanks a lot that was very nice and valuable information.
    just want to ask which palette i have to use to save the value 1 or 2 when user press 1 or 2.
    I know using Menu we can create different Menu option.
    After user press 1 it will go SALES skill group and if press 2 Go MARKETING Skill group.
    Appreciate if you can help me in this regard.
    Regards
    Debashis

  • Simple BASH script to update subversion files

    This is just a simple BASH script that will update all .svn files in a specified directory.  If an update fails, it will attempt to update all the subdirectories in the failed one, so as much will be updated as possible.  Theoretically, you should be able to supply this script with only your root directory ( / ), and all the .svn files on your computer will be updated.
    #! /bin/bash
    # Contributor: Dylon Edwards <[email protected]>
    # ================================
    # svnup: Updates subversion files.
    # ================================
    #  If the user supplies no arguments
    #+ then, update the current directory
    #+ else, update each of those specified
    [[ $# == 0 ]] \
        && dirs=($PWD) \
        || dirs=($@)
    # Update the target directories
    for target in ${dirs[@]}; do
        # If the target file contains a .svn file
        if [[ -d $target/.svn ]]; then
            # Update the target
            svn up $target || {
                # If the update fails, update each of its subdirectories
                for subdir in $( ls $target ); do
                    [[ -d $target/$subdir ]] &&
                        ( svnup $target/$subdir )
                done
        # If the target file doesn't contain a .svn file
        else
            # Update each of its subdirectories
            for subdir in $( ls $target ); do
                [[ -d $target/$subdir ]] &&
                    ( svnup $target/$subdir )
            done;
        fi
    done

    Cerebral wrote:
    To filter out blank lines, you could just modify the awk command:
    ${exec awk '!/^$/ { print "-", $_ }' stuffigottado.txt}
    very nice; awk and grep: two commands that never cease to amaze me.

  • Create a simple shell script thing?

    Hey,
    I'm trying to make a simple command script thing. I have no idea what I'm doing though.
    I just want a file that I can click and open in terminal that will:
    1. ssh [email protected]
    2. auto enter the password (if this is really complicated then it can be skipped)
    3. cd public_html/blog
    4. svn up
    5. like 5 sec delayed exit (if possible)
    I'm thinking this is a really easy thing to do for someone who knows what they're doing.
    So can someone tell me what I have to do to make this? I would really like to learn how to do this.
    Thank you
    Last edited by FLCLFan (2008-10-12 20:06:20)

    Instead of making a script, you could just as well write a bash function for this and put it in your .bashrc.
    something like this:
    update-svn-on-domain ()
    ssh -t [email protected] 'svn up public_html/blog'
    when the svn up is done, the ssh command stops, and the function returns.  it does everything you want except auto entering passwords. 
    i strongly discourage auto entering passwords.  i recommend you to setup rsa key authentication

  • Resizing Script Exports in Low Quality

    Hello. A while back I found an image resizing script on these forums. Recently it's JPEG outputs have seemed to be on low quality, like 30%. How can I change this script-application to export resized images in a higher quality?
    Thanks, and the script is below.
    on open some_items
    repeat with this_item in some_items
    try
    rescaleand_save(thisitem)
    end try
    end repeat
    end open
    to rescaleand_save(thisitem)
    tell application "Image Events"
    launch
    set the target_height to 256
    -- open the image file
    set this_image to open this_item
    set typ to this_image's file type
    copy dimensions of this_image to {current_width, current_height}
    if current_height is greater than current_width then
    scale this_image to size target_height
    else
    -- figure out new height
    -- y2 = (y1 * x2) / x1
    set the new_width to (current_width * target_height) / current_height
    scale this_image to size new_width
    end if
    tell application "Finder" to set new_item to ¬
    (container of this_item as string) & "256_" & (name of this_item)
    save this_image in new_item as typ
    end tell
    end rescaleandsave

    You can't control the jpeg compression quality using Image Events. You can with iMagine Photo. iMagine Photo is free, and is like a more powerful version of Image Events.
    You can read about iMagine Photo here:
    http://www.yvs.eu.com/imagine.html
    You can download iMagine Photo from here:
    http://www.yvs.eu.com/downloading.html
    iMagin Photo documentation is here:
    http://www.yvs.eu.com/documentation.html
    Follows is a script that will allow you to specify the compression quality while scaling. The quality difference between maximum and lossless is tiny while the file size difference is quite large so I don't normally recommend lossless.
    The script does not copy the exif information to the scaled image file, but iMagine Photo can copy the exif information, and or modify certain exif types.
    The script replaces the contents of the original file - so beware.
    Kevin
    ---- begin script
    property theScale : 0.5 -- 50% scaling
    using terms from application "iMagine Photo"
    property exportQuality : high -- minimum / low / medium / high / maximum / lossless
    end using terms from
    on run
    -- this script replaces the contents of the original file
    set thisFile to choose file with prompt "Choose an image file to scale: "
    tell application "iMagine Photo"
    set thisImporter to import graphic thisFile
    if the component error of thisImporter is not equal to 0 then
    close thisImporter
    return
    end if
    tell thisImporter to make exporter with properties {export file type:"JPEG", export file location:thisFile, export compression quality:exportQuality}
    set scale of thisImporter to {theScale, theScale}
    export thisImporter
    close thisImporter
    end tell
    end run
    ---- end script

  • Creating simple shell script packages to deploy with ARD and TaskServer

    I am looking for a simple step by step on how to create a package that can be deployed using ARD, to run a simple shell script like
    "softwareupdate -i -a"
    A brief search here returned nothing, but perhaps I was not using the correct terms.
    Ultimately, I want to use ARD to run software update on ~400 Macs.
    Thanks in advance for your help.
    Bill

    If I send it as a unix command, it will run only on machines that are currently awake and responding to ARD.
    If I can set it up as a package, then I can use Task Server to "deploy" the command to machines that are not currently online. When the machines next contact the Task Server, they will be told to run softwareupdate.

  • Simple button script not working

    I am using AS2 and need help figuring out why this simple button script is not working:
    stop();
    buttonWS1.onRelease = function(){
                        gotoAndStop("Stage1and2_Boss",4);
    buttonWS2.onRelease = function(){
                        nextFrame();
    //end
    My buttons are the square letter-puzzles below. They are images that I converted to "symbols" (specifically, buttons). I put their names as above (buttonWS1, buttonWS2, etc.) in the "instance names" boxes.
    I have no idea what is going on. Please help!

    Hi -
    1. Yes, buttonWS2 is the instance name
    2. The only code attached to it is the code I pasted above.
    3. onRelease does not execute because my trace statement does not appear in the output
    Here is the modified code for buttonWS2:
    buttonWS2.onRelease = function(){
                        trace("clicked!");
                        nextFrame();
    Question: It shouldn't matter if I have commented-out code within that set of codes should it?:
    buttonWS2.onRelease = function(){
              //if (puzzleschosenarray[0] == 2 || puzzleschosenarray[1] == 2) {
              // cannot be chosen -- make button non-functional
              //else{
                        //puzzleschosenarray[roundnumber-1] = 2;
                        trace("clicked!");
                        nextFrame();

  • I have a 2010 Macbook Pro and am a very new user to Mac community. My Mac is just hanging and I am unable to shut it down or do anything at all.  I left it for 2.5 days hoping the battery will run flat but it is not working. Pls help! I am desperate. Tx

    I have a 2010 Macbook Pro and am a very new user to Mac community only started to use this PC a few weeks ago.
    My Mac is just hanging and I am unable to shut it down or do anything at all.  I left it for 2.5 days hoping the battery will run flat but it is not working. Pls help! I am desperate. Tx

    In order to resolve the issue if it occurs again, more info would be helpful as to what occurred prior to the "hang." One potential fix would be to try a Safe Boot:
    After the Mac is completely shut down, push the power button and immediately after the startup tone, hold down the Shift key. The Shift key should be held as soon as possible after the startup tone but not before.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    There should be a message that says "SafeBoot." After the Mac is completely booted, try restarting and see if the issue is gone.

  • I want to know when the Firefox 27.0 that's not beta version will releases on Windows.

    I know the Firefix beta has been released for Windows on last week.
    So in the futere, the Firefox beta version will be just Firefox. Do you understand about my saying? I'm sorry for my poor skill making grammer. But I would like to know the date that the Firefox 27.0 is officially released. Thank you for listen to me. I will wait for your answer.

    Is the current version of Firefox 27.0.1 a "regular version" or is it still the beta version? I had a new operating system installed on February 13th, and the version downloaded was version 27. Only having one problem, and that is blocking one cookie. I have never used a beta version and only want the regular version.
    Need to know if the version as of Feb. 13th is the regular version. I have no way of finding out which version it is. Thank you for any help with this question.

  • Tidy -- simple python script to clean annoying files and directories

    Hi all,
    recently I opened a much-used flash drive and there was a lot of files like Thumbs.db, Mac OS' ._*, .DS_Store, etc all over it, making using it really annoying.
    So I decided to mimic a simple utility I saw as a plugin in Rockbox, which takes all of these files and deletes them.
    The result is a simple python script which you can find at:
    http://github.com/houbysoft/short/blob/master/tidy
    Usage should be self-explanatory. Be warned, by default, it deletes everything that matches the regular expressions without warning (this should be fine though, so if you want to be safe, try the -s and -v (simulate, verbose) or -p (prompt) options first.
    As usual, any feedback is welcome, and if you know of other files it should clean, please post them here!

    Hi all,
    recently I opened a much-used flash drive and there was a lot of files like Thumbs.db, Mac OS' ._*, .DS_Store, etc all over it, making using it really annoying.
    So I decided to mimic a simple utility I saw as a plugin in Rockbox, which takes all of these files and deletes them.
    The result is a simple python script which you can find at:
    http://github.com/houbysoft/short/blob/master/tidy
    Usage should be self-explanatory. Be warned, by default, it deletes everything that matches the regular expressions without warning (this should be fine though, so if you want to be safe, try the -s and -v (simulate, verbose) or -p (prompt) options first.
    As usual, any feedback is welcome, and if you know of other files it should clean, please post them here!

  • I lost my iphone4 and replaced it with a 4s. It's been a year since my last sync. Do I set up my phone as "new" or "restore from backup?" Im hoping game center will automatically have a current record of game data...please help or advise.thx

    I lost my iphone4 and replaced it with a 4s. It's been a year since my last sync. Do I set up my phone as "new" or "restore from backup?" Im hoping game center will automatically have a current record of game data...please help or advise.thx

    Restore from backup.

Maybe you are looking for