Square script mystery

Greetings!
Photoshop CS5, iMac June 2010 ,8 GB Ram, OS 10.7
Have a script, which takes any image and makes it square by comparing the height and width. Trouble is, I can run this on single images without problem, but when I try to put it in a batch the prefernces panel comes up on Units and Rulers, and does so for every single image. If I try to cancel the script it give me an error message about line 2.
Here's the script (ExtendScript Toolkit CS5):
var savedRuler= app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
//if w==h already square
app.preferences.rulerUnits = savedRuler;
When I tried to remove the first two lines the script stops and opens the Canvas Size dialog box, once again for each image.
I'd liek to get this to work in a batch. Can anyone give some advice on this?
Thanks ahead of time!

You also need the first two lines or you need to retrieve the ruler units to make sure your if statements will do what you want. For if ruler units is set to  percent width will always be 100% and height will always be 100%  w will = y and the document may or may not be square. If the document contains a background layer you may also want to set the color its added canvas will be.

Similar Messages

  • DreamWeaver Flash Scripting Mystery

    DW 6 cannot view photo galleries created with Lightroom if they have Flash content.  When a file with flash content (e.g. index.html0 is opened, the design view in DW says, "Sorry, this photo gallery requires that scripting be enabled on your web browser and that the Adobe Flash Player be installed.  Download the Adobe Flash Player".  I have enabled Java scriping in both Firefox and IE and both browsers recognize the presence of Flash. This problem does not occur when the index.html file has no Flash content.  However,  html files with Flash content can be previewed in Firefox but not in IE, where the same error message occurs.  All this is in a new Win 8 PC.  Any suggestions on solving this mystery will be much appreciated.
    Jim

    Thanks for your input Sudarshan.  The script and noscript tags are present (Although I do not know how these lines got into my code.) Removing them eliminates the error message but the design view pane is still blank.  Firefox option is set to enable Java Script.  The html can be successfully previewed.  Doesn't this confirm presence of Java Script?  Here is a snippet of the code:
    </script>
    <noscript>
                    <!-- Provide alternate content for browsers that do not support scripting
                         or for those that have scripting disabled. -->
                    <p>
                    Sorry, this photo gallery requires that scripting be enabled on your web browser and that the Adobe Flash Player be installed.
                    <a href="http://www.adobe.com/go/getflash/">Download the Adobe Flash Player</a>
                    </p>
    </noscript>

  • Action Script Mysteriously Changing width of Items ???

    Hello,
    I am working on this website and I decided to add some flash to the front page in the form  of a little image gallery with a nifty slide effect.
    The problem is this. For some reason its squishing my  images. When you look in the scripting you will see that I've set the image  width to the full width of the stage, but when you test the movie they are  getting squished to about 3/4th's the width of the stage (ive double checked the image size as well).
    Hopefully you will see something I have  missed.
    Thanks for your help, this is  bugging me to no end!
    -Brian

    While the problem has nothing to do with the actionscript, you posted this in the wrong forum since the file uses AS2.
    The problem has to do with having modified the scale of the movieclips into which the images are loaded.  If you open the imgscroller movieclip, select all of the little white squares in the upper left (clip1 thru clip7), and select Modify -> Remove Transform, it will restore them to normal scale.

  • Scripting mystery

    Ok, so I've got a movie clip with a 1st frame which is acting like a "home page" for purposes of this thread. In frames 2-4, I've got three sub-clips which play when prompted by buttons placed on a "buttons" layer in frame 1. In this "buttons" layer, there is a "back" button which appears on frame 2-4 and takes the viewer from frames 2-4 back "home" (to frame 1).
    The "back" button sends me back to frame 1 (home) when I am on the frame 2 sub-clip, but it doesn't take me "home" from the clips on frames 3-4.
    Here's my script which is working for frame 2's sub-clip, but won't work for frames' 3-4 sub-clips:
    stop();
    guitarBack_btn.addEventListener(MouseEvent.CLICK,goFrame1);
    function goFrame1(Event:MouseEvent):void {
    gotoAndPlay(1);
    Why does the above script activate the "back" button for the clip on Frame 2, but not the two on Frames 3 and 4? Any ideas?
    Thank you!

    In frame 1 use...
    guitarBack_btn.visible = false;
    and in the event handler functions for the frame 1 menu buttons use...
    guitarBack_btn.visible = true;
    That way it will turn invisible anytime it enters frame 1, and when you click a menu button it will be made visible.  An invisible button cannot be interacted with (but one with alpha = 0 can).

  • Weird square box mysteriously appears

    Occasionally after editing a photo in ACR and opening it in Photoshop CS4, a square box appears in the photo, as if I selected a small square area and darkened it using curves. Any thoughts about how to prevent this or how to get rid of the box if it happens? I am using a Mac Pro tower with the latest OS 10.6 (although I remember it happening once using OS 10.4) and the most updated version of CS4. Thanks!!

    This is a very strange problem. Sounds to me like some sort of graphics card glitch more than anything else.
    Is Camera RAW  genuinely rendering a square selection darker than the surrounding pixels? when you move the image around your monitor, and measure the pixels with the eyedropper is this still apparent?
    Since its most likely to be what I suggested above - try turning Open GL on and off in Preferences.

  • Apple script mystery

    I've just created a script that copies the text I have selected in Safari, pastes it into a new Textedit document, and also pastes in the URL of the current page from Safari.
    It works fine when I open it up in Script Editor, and then run it. But when I saved it to the Scripts folder, then run it from the scripts menu, Safari doesn't copy the selected text to the clipboard.
    The command to tell Safari to copy the selected text to the clipboard is this:
    tell application "Safari"
    activate
    end tell
    tell application "System Events"
    tell process "Safari"
    click menu item "Copy" of menu "Edit" of menu bar 1
    end tell
    end tell
    Why do scripts behave differently when run from Script editor as when run from the scripts menu?

    It works for me on a 10.3.9 Mac. I won't be able to check 10.4.3 until I get home.
    iMac G5 20"   Mac OS X (10.4.3)  

  • Weird scripts in corrupted RH9 project

    Hi!
    I'm having trouble with a small 75-topic project in RH9. I just upgraded it from RH7 last month. The application runs on XP, service pack 3. The project file is located on a desktop and has a short access path (c:\RH9Projects\). I have in all 4 small RH projects, and created backups for each before upgrading to RH9. For simplicity purposes, the corrupted project will be identified as project A, and the others as B, C and D.
    After I finished tweaking the upgraded files and cleaning up unnecessary html in project A a few weeks ago, I generated my regular webhelp output and published it on the web. Everything was running smoothly. Since that upgrade from 7 to 9 went well, I repeated the steps for projects B, C and D. All was well again. I had also created backups at that time.
    Yesterday I went back to project A, and a lot of things are wrong. The TOC pod is empty, images that were in drop-down hotspots have disappeared and weird scripts have appeared in the topics' html. I first noticed those dreaded red squares at the top of all topics, sometimes 1 or 2. They also appear at the bottom of the topics.
    I closed project A without saving and tried opening project B. Everything is fine, nothing is missing. Same thing for project C and D. I tried opening a backed up copy of project A and that one too is corrupted. The backup copy was in a different folder but still with a short path. In this one, however, the opning topic is blank and has 6 red squares.
    Here's the script corresponding to the red square at the top of the topic:
    <script type="text/javascript" language="javascript1.2">//<![CDATA[
    <!--
    if (window.gbWhTopic)
            var strUrl = document.location.href;
            var bc = 0;
            var n = strUrl.toLowerCase().indexOf("bc-");
            if(n != -1)
                    document.location.href = strUrl.substring(0, n);
                    bc = strUrl.substring(n+3);
            if (window.addTocInfo)
            addTocInfo("Aide en ligne JMS");
    addButton("show",BTN_TEXT,"Afficher","","","","",0,0,"","","");
            if (window.writeBtnStyle)
                    writeBtnStyle();
            if (window.writeIntopicBar)
                    writeIntopicBar(1);
            document.write("<p style=\"text-align:right\"> ");
    AddMasterBreadcrumbs("H_HLP_FR.htm", "", "&gt;", "Home", "1000.htm");
    document.write("Aide en ligne JMS<\/p>");
            if (window.setRelStartPage)
            setRelStartPage("H_HLP_FR.htm");
                    autoSync(1);
                    sendSyncInfo();
                    sendAveInfoOut();
    else
            if (window.gbIE4)
                    document.location.reload();
    //-->
    //]]></script>
    Here's the script corresponding to the red square at the bottom of the topic:
    <script type="text/javascript" language="javascript1.2">//<![CDATA[
    <!--
    if (window.writeIntopicBar)
            writeIntopicBar(0);
    highlightSearch();
    //-->
    //]]></script>
    In some cases I also see this script - from a second red square:
    <script src="../../../ehlpdhtm.js" type="text/javascript" language="JavaScript1.2"></script>(top)
    <script type="text/javascript" language="JavaScript1.2">//<![CDATA[
            if( typeof( TextPopupInit ) != 'function' ) TextPopupInit = new Function();
            TextPopupInit('a1','POPUP386155265');
            TextPopupInit('a2','POPUP386287878');
    //]]></script>(bottom)
    All RH9 versions of project A, original file and backup files, have this problem. If I open project A backup file using RH7, the file is okay. I know I can still start over with a new upgrade if need be, but I'm trying to figure out what happened. Everything was fine on April 20
    Aside from a techsupport guy, I am the only one who accesses this computer. There are no known technical issues with it. It is not connected to the Internet, only to the company's network, and security is thight.
    Does anyone have any clue as to what might have happened?
    Thank you in advance
    Nathalie

    Hi there
    Well it would appear that somehow you managed to copy your generated WebHelp output files over your pristine source files. Time to resort to your backup.
    You, ummm, DO have a backup. Right?
    In case you don't, follow the link below.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • OSX 10.6 does not differentiate between PS or illustrator .eps files

    Have other people encountered this problem?
    I have found that snow leopard does not differentiate between photoshop and illustrator .eps files in order to double click and open them.
    Does anyone know how to correct this?

    Hello Chris,
    Thanks so much for clarifying about OSX 10.6 opening .eps files in illustrator or photoshop.
    I was wondering if you knew out how
    to create a droplet that opens multiple PDFs and saves as .gifs.
    When I
    try to do it, all of the .gifs end up having the same name as the file
    that I created the script with, and a "-1" at the end.
    Actually
    there are two droplets that I want to create (to be able to
    drop multiple pdf files):
    Portrait/Square
    script:
    Final thumbnail file to be 51 pixels wide by (x?) pixels
    tall
    Final thumbnail file should be 72 dpi,
    Final
    thumbnail file should be flattened(no transparency in white areas),
    Final thumbnail file should have a 1 pixel wide Grey border to all
    sides
    Final thumbnail file should be saved as a GIF file, RGB
    Landscape script:
    Final thumbnail file to be 65 pixels wide by (x?)
    pixels tall
    Final thumbnail file should be 72 dpi,
    Final
    thumbnail file should be flattened(no transparency in  white areas),
    Final thumbnail file should have a 1 pixel wide Grey border to all
    sides
    Final thumbnail file should be saved as a GIF file, RGB
      Thanks,
    Matthew
    Date: Wed, 14 Apr 2010 14:48:11 -0600
    From: [email protected]
    To: [email protected]
    Subject: OSX 10.6 does not differentiate between PS or illustrator .eps files
    Given EPS files are "really" Illustrator files (Photoshop not being a
    vector application), you probably want to make Illustrator the default.
    No.
    EPS files can be produced and read by many applications.
    And most EPS files cannot be read by Illustrator.
    Frequently EPS files in particular need to be edited in the application which created them (Freehand vs. AI vs. Quark gradients anyone?).
    >

  • Mystery - One scripts folder works - the other doesn't

    I've been using some of Doug's great iTunes scripts <http://dougscripts.com/itunes/> for a couple of years, but the following unsolved mystery is driving me nuts:
    According to his ReadMe files (and other documentation), there are two locations where iTunes scripts can be placed:
    (1) user name > Library > iTunes > Scripts
    or
    (2) user name > Library > Scripts > Applications > iTunes
    Doug's scripts even come with an installer that places scripts in location #1. My problem is that _*no matter what I do, scripts that I place in location #1 do not show up in the Script Menu._* (Of course I mean when iTunes is the frontmost application.)
    Scripts in location #2 work fine -- so that's where I always place mine -- but there are advantages to location #1, such as (a) assigning keyboard shortcuts to scripts via System Preferences > Keyboard & Mouse, and (b) Doug's installers, which I can't use; so I always have to install my scripts manually.
    Frustrated, I've simply accepted this for some time now. But after installing some new scripts recently, this issue is nagging me, once again. Hence this post.
    What could possibly be preventing location #1 from working for me, when it apparently works fine for others?

    Create and log in into a new account.
    Install a doug script.
    Launch 'iTunes'.
    View the menu items of the 'iTunes' script menu.
    If you see and can execute the doug script, via 'iTunes' script menu, you verified a problem specific to your origianl user account.
    If so, consider booting from the installation disc, and perform a 'Disk Utility' 'Repair Disk' action.
    Log in into the original account and see if the 'iTunes' script menu is now functional.
    If either - the new account and / or 'Repair Disk' suggestion(s) fail - consider the new Mac way (originally a 'Windoze' only way) to resolve System level problems - reinstall MacOS X, and enjoy the time spent updating MacOS X.

  • Need a script for squaring images of various sizes please

    Hello, new to this group but have been using photoshop for years doing basic editing. I have never done any sripting. I have a project on my hands. I have a lot of image of various sizes with some taller or wider than others. I need to make all these images exactly square though. Currently they vary and are wider or taller etc.
    I was wondering what process I could use hopefully with batch editing but was told scripting might be the answer to automate this process as I have about 8,000 images.
    So for example one image might be 200 pixels wide and 400 pixels high and another is 100 pixels high and 600 pixels wide and so on. I would need the
    1st example to be 400 x 400 and the 2nd example 600 x 600.
    I am using photoshop 5.5
    The software for a shopping cart is using a feature that allows you to zoom in on the image but if it is not perfectly square the image doesn't appear
    well in the software. Using magento e-commerce.
    Thanks for your help and any thoughts on this project of mine.
    Dave

    Here a simple script the does what I think you want.
    // squares the canvas. uses the background color
    var doc = activeDocument;
    var maxDim = Math.max( doc.width, doc.height );
    doc.resizeCanvas( maxDim, maxDim, AnchorPosition.MIDDLECENTER );

  • Script or Action - Make image square

    Need to add this to an action, rather than making all images square manually before batching them all.
    - All 500+ images are various sizes both portait, landscape and possibly square already.
    - They are all cropped tightly around the product with a white background.
    So currently: I just use canvas size, anchor to the centre and change the smallest pixel dimension to make it square, so none of the product is cropped.
    Any ideas?
    I couldn't get JJMack's aspect ratio script to help me.
    Automate -> Fit Image will take it to 1000 pixels but still won't be square.
    EDIT: Oh my. I just found this, looks like it'll do the job. Will test some more in the morning.
    var savedRuler= app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var w = app.activeDocument.width;
    var h = app.activeDocument.height;
    if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
    if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
    //if w==h already square
    app.preferences.rulerUnits = savedRuler;

    I have a need for this script as well...is this the entire script?  If not, can you post the complete script?
    I just need to increase either the canvas width (as white area for the added width/height) or the canvas height to match the longest side of an image so they they are perfectly square.  No cropping or reduction in image sizes.  These are product images on white background.
    Is this the full script?
    var startColor = app.backgroundColor; 
    if(startColor.rgb.hexValue != 'FFFFFF'){ 
    var white = new SolidColor(); 
    white.rgb.hexValue = 'FFFFFF'; 
    app.backgroundColor = white; 
    var savedRuler= app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var w = app.activeDocument.width;
    var h = app.activeDocument.height;
    if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
    if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
    //if w==h already square
    app.preferences.rulerUnits = savedRuler;
    if(white != undefined) app.backgroundColor = startColor; 

  • Mysterious square

    I'm building a shopping cart for a gallery site. I hadn't
    even worked on it for a week, but when I checked it yesterday,
    there was a strange problem. When you click directly on the
    datagrid a mysterious green square appears. The square doesn't
    inherit the transform of the data grid, but it does inherit the
    alpha value. The really strange thing is that it only happens when
    I post the files online. There is no problem when testing locally.
    I've talked to tech support and they were stumped.... Can anyone
    help? (please don't try to purchase anything, the site is far from
    finished)
    the data grid comes up when you press add to cart or show
    cart
    http://danielbourdet.com/susanbourdet/SBgallery.html

    Thanks for helping Rothock. I messed around with focus
    manager and eventually just disabled tabbing, but the square
    remains. While I haven't found a way to completely get rid of the
    square, I have found a way around the problem.
    I guess the data grid didn't like being scaled for some
    reason. The square was the outline of the data grid at 100 scale, I
    had it at 130. I reset the scale to 100 and the square still
    appears, but is now on the outline and is not so distracting.
    http://danielbourdet.com/susanbourdet/SBgallery.html

  • Canvas Resize to Square for a large number of images using script. E.g. image is currently 1020 x 600, I would like to change this to 1020 x 600. PLEASE HELP

    Hi All,
    I have a large number of images that I need to resize the canvas sizes to a square, the images are currently in different sizes. For example, if an image is 1020 x 600 I would like to change the canvas to 1020 x 1020 so that the image becomes a square. I am using CS3 and all the images are jpeg's. I have done research on scripts but the ones I have tried have not worked. Please help.
    Thanks.

    Since you do not want to crop your images to a square 1:1 aspect ratio changing the canvas to be square will not make your images square they will retain their Aspect Ratio and  image size will be changer to fit within your 1020 px square. There will be a border or borders on a side or two borders on opposite sides.   You do not need a script because Photoshop ships with a Plug-in script to be used in Actions.   What is good about Plugins is the support Actions.  When you record the action the plug-in during action recording records the setting you use in its dialog into  the actions step.  When the Action is played the Plug-in use the recorded setting an bypasses displaying its dialog. So the Action can be Batch.  The Action you would record would have two  Steps.   Step 1  menu File>Automate>Fit Image... in the Fit Image dialog enter 1020 in the width and height  fields.  Step 2 Canvas size enter 1020 pixels in width and height  not relative leave the anchor point centered it you want even borders on two sides set color to white in the canvas size dialog. You can batch the action.
    The above script will also work. Its squares the document then re-sizes to 1020x1020  the action re-sizes the image to fit with in an area 1020 x 1020 then add any missing canvas. The script like the action only process one image so it would also need to be batched. Record the script into and action and batch the action. As the author wrote. The script re size canvas did not specify an anchor point so the default center anchor point is uses  like the action canvas will be added to two sides.

  • Mystery white square at launch

    Hi,
    I'm not a web designer and am very new to Golive and anything web-based. I've just taught myself how to edit the existing website in our company which uses Adobe flash and golive. It's all good and up and running, but there's one last thing that I can't figure out.  Here's the website:  www.formartarchitects.co.uk
    You'll notice that when you open it, just before the homepage comes up, a large white square flashes up. I realise this may have something to do with the index.html in golive - but as I didn't set the site up and have just tinkered with what was already set up by someone else - I'm unsure what to do.
    Does this look like an obvious issue that someone could explain to me how to fix? Please bear in mind that technical lingo may be lost on me...!
    Thanks so much for your help.

    You are welcome, ioyome.
    I believe it is better to leave it white because it sets the frame and focusses the attention.
    Actually, before anything appears, it says Loading, but that may be too brief to notcie, depending on the loading time. You may try to open it elsewhere with faster/slower connexions and see how it works before deciding anything.
    And if you do need to change something you should also ask in the relevant Flash forum (see the different ones under Forums).
    http://forums.adobe.com/community/flash

  • Script to make landscape and portrait images square

    I am new to scripting and could use a little help.
    We are currently rebuilding our enitre website from the ground up. New look, new products, new images (about 2,800 of them). Here is where it gets tricky.
    Some of the photos are landscape and others are portrait. I have resized the images to the required 200 pixels wide, but we are now running into the issue where they also need to be 200 pixels high. I could just separate them into two folders, landscape and portrait, and run two different actions, but I would prefer to run an if/than script if possible. Can someone tell me if this is possible in Photoshop? These are images of products, so there is no background.
    If the image is larger than 200 pixels high, reduce the image to 200 pixels high. Then, enlarge the canvas to 200 pixels.
    If the image is smaller than 200 pixels high, Then enlarge the canvas to 200 pixels high.
    These are all 72 dpi, RGB images. Any help would be greatly appreciated.

    I have found this JaveScript that does what I need on the PC side, but keep getting an error when it tries to save the image. Is anyone able to recreate this into AppleScript with a correct save function... I am running a MAC, so I need an AppleScript. My coworker has Photoshop on the PC and is trying to use this JavaScript below.
    //  resize canvas  & export JPG
    #target photoshop
    app.bringToFront();
    // Save current dialog preferences
    var startDisplayDialogs = app.displayDialogs;    
    // Save current unit preferences
    app.displayDialogs = DialogModes.NO
    // Source and Destination Folders
    var inputFolder = Folder.selectDialog("Select the Source folder");
    var outputFolder = Folder.selectDialog("Select the Destination folder");
    ProcessImages();
    function ProcessImages() {
      var filesOpened = 0;
       if ( inputFolder == null || outputFolder == null) {
       if ( inputFolder == null) {
                alert("No Source folder selected");
        if ( outputFolder == null) {
           alert("No Destination folder selected");
       }else{
    var fileList = inputFolder.getFiles();
      for ( var i = 0; i < fileList.length; i++ ) {
           if ( fileList[i] instanceof File && ! fileList[i].hidden) {
                     open( fileList[i] );
                     ResizeCanvas();
                     filesOpened++; 
      return filesOpened;
    function ExportJpeg(filePrefix, fileSuffix){
    try
    var docRef = app.activeDocument;
    var docName = app.activeDocument.name.slice(0,-4);
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 8
    docRef.flatten()
    docRef.bitsPerChannel = BitsPerChannelType.EIGHT
    jpegFile = new File( outputFolder + "//"  + filePrefix + docName + fileSuffix );
    //Save Document As
    docRef.saveAs(jpegFile, JPEGSaveOptions, true, Extension.LOWERCASE);
    catch (e)
    alert("Error when attempting to save the image. \r\r" + e);
    return;
    function ResizeCanvas()
       function CanvasSize() {
          var docRef = app.activeDocument;
          var docWidth = docRef.width.as("px");
          var docHeight = docRef.height.as("px");  
          if (docWidth < docHeight)
                docRef.resizeCanvas(docWidth = docHeight, docWidth, AnchorPosition.MIDDLECENTER);
          else if (docWidth > docHeight)
                docRef.resizeCanvas(docHeight = docWidth, docHeight, AnchorPosition.MIDDLECENTER);
          else if (docWidth == docHeight)
    var docRef = app.activeDocument;
    var savedState = docRef.activeHistoryState;
    CanvasSize();
    app.displayDialogs = DialogModes.NO;
    ExportJpeg("", ".jpg");
    docRef.activeHistoryState = savedState;
    docRef.close(SaveOptions.DONOTSAVECHANGES);
    docRef = null;
    // Reset preferences
    app.displayDialogs = startDisplayDialogs;
    alert("Operation Complete!" + "\n" + "Images were successfully exported to:" + "\n" + "\n" + outputFolder.toString().match(/([^\.]+)/)[1] + "/");

Maybe you are looking for