Skip navigation
msloumaria
Currently Being Moderated

Action records layer transform in percentage NOT pixels???

Apr 11, 2012 2:45 AM

Hello, I really need your help.


I am trying to create an action that will help me with some product images. Every image document I make is the same size (1000 x 1000px). The layer that I paste onto that document will always vary in size. I like my product images to all have the exact same margin. So I always use the transform command to specify that the width of any layer should be exactly 930px. This gives me exactly the same margin on my 1000 x 1000px document every time, regardless of the original layer size. I want to create an action for this to speed up the process but when I press record I hit a stumbling block.


In reality, I choose transform and set width to 930px.


Photoshop records me choosing transform then setting the width to 97% (or whatever).


Percentages are useless to me as my original layers vary radically in size. I need to transform by pixels.


Can anybody suggest why photoshop is recording my transform by percentage and not the pixels that I actually use?


HELP!!

 
Replies
  • Pierre Courtejoie
    7,038 posts
    Jan 11, 2006
    Currently Being Moderated
    Apr 11, 2012 3:36 AM   in reply to msloumaria

    Hello, in the beginning of the action, record changing the units to percentage.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Apr 12, 2012 1:44 AM   in reply to msloumaria

    Edit>Preferences>Units.

     

    Photoshop Actions Recorder use Photoshop's current ruler units setting when recording some steps that involve a size.  You do not need to record the setting of the Preferences Units setting, you just need to have the setting correct for what you want recorded when you record the step. You can stop recording change the setting then continue the recording.

     

    If you record the step Edit>Preferences>Ruler Units and give the action to others to use, it will change their setting which they don't expect and they may have a hard time tracking down what is changing their setting on them.

     

    Ruler units and a Document DPI setting are very important when actions are recorded.  When ruler units is pixels steps are recorded in absolute pixel sizes.   Other settings in the same step will be recorded in a relative way.

    When % relative to the current document current canvas size.   Units like Inches cause steps to work relative to the current document current DPI resolution. So it is also important to have Document DPI set to a reasonable value. You do not want a print size image set to 72 or a web size image set to 300dpi.

     

    Many steps can be recorded in a relative or absolute way.  Some steps like adding Layer styles can only be recorded using Absolute pixel setting which makes adding layer style to image layers a big problem when you have no idea of the document scaling DPI resolution or if the image is print size or Web size.  Where a Web size layer would need a few pixels a print size layer would need many pixels.

     

    It would much better if layer style effects could be recorded relative to size. I had to write some utility scripts to be use with in my actions to address some of the limitations of actions and to deal with document sizes..

     

    My Crafting Actions Package contains

    • Action Actions Palette Tips.txt
    • Action Creation Guidelines.txt
    • Action Dealing with Image Size.txt
    • Action Enhanced via Scripted Photoshop Functions.txt
    • CraftedActions.atn Sample Action set includes an example Watermarking action
    • Sample Actions.txt Photoshop CraftedActions set saved as a text file.
    • 12 Scripts for actions

    Download

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 5:45 AM   in reply to msloumaria

    Changing the UNITS still will not work as Photoshop will still convert it to a percentage.

    There is a way, and that is to use a script.

     

     

     

    #target photoshop
    function main(){
    if(!documents.length) return;
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var doc = activeDocument;
    var res= doc.resolution;
    var LB = activeDocument.activeLayer.bounds;
    var Width= LB[2].value - LB[0].value;
    var onePix = 100/Width;
    var newSize = onePix * 930;
    doc.activeLayer.resize( newSize , newSize, AnchorPosition.MIDDLECENTER); 
    app.preferences.rulerUnits = startRulerUnits;
    }
    main();
    
    

     

    This script can be called from your action (File - Scripts - selected the script)

    It will resize the active layer to 930 pixels width constraining the height.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 6:54 AM   in reply to msloumaria

    Copy and paste the code into ExtendScript Toolkit.

    This utility can be found:-

    PC: C:\Program Files\Adobe\Adobe Utilities

    PC 64 bit C:\Program Files (x86)\Adobe\Adobe Utilities - CS#

    MAC: <hard drive>/Applications/Utilities/Adobe Utilities

     

    Save the script to the following folder:-

    PC: C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts

     

     

    MAC: <hard drive>/Applications/Adobe Photoshop CS5#/Presets/Scripts

     

    # being the CS version of Photoshop.

     

    N.B. if your are using Vista or Windows 7 you will need to save the script elsewhere and then copy it to the relevant folder, this is due to permissions.

     

    If Photoshop was open close and restart it so that it can pick up the new script.

     

    To assign an action , start recording a new action, then from the action palette fly-out menu select "Insert Menu Item" now File - Scripts and select your new script. Stop the recording.

     

     

    Hope this helps.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 8:37 AM   in reply to msloumaria

    To do the height it would be...

     

     

    #target photoshop
    function main(){
    if(!documents.length) return;
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var doc = activeDocument;
    var res= doc.resolution;
    var LB = activeDocument.activeLayer.bounds;
    var Height= LB[3].value - LB[1].value;
    var onePix = 100/Height;
    var newSize = onePix * 930;
    doc.activeLayer.resize( newSize , newSize, AnchorPosition.MIDDLECENTER); 
    app.preferences.rulerUnits = startRulerUnits;
    }
    main();
    
    
     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Apr 12, 2012 1:49 AM   in reply to msloumaria

    What you want to do is best done with a script like Paul gave you for you have no idea of the current clipboard size and a layers the is pasted in can be  greater then less then and equal to a documents canvas size.

     

    However Still Ruler Units Setting effect the way some actions steps are recorded.  As I wrote Settings like Ruler Unites and DPI resolution effect the way steps are recorded and play.

     

    Tools like Transform do many things; changing size is only part of what the transform tool does.  When you record it use in an action only the changes made during the use of the transform tool are recorded when you commit the transform.

     

    When you record an action you should fully expand the steps that are recorded so you can see what the step changes and how:

     

    Changing only a layer size will only record that change and it will be recorded in a percentage change from its starting size. If you only change its width, only one size change is recorded.

    However Transform can also move layers, rotate layers around its center or another point.

     

    A transform step may have many changes recorded in it.  When a move is involved the move is recorded relative to the anchor point location where ever you place it, so its location needs to be recorded and the size of the move is recorded using the current ruler units setting, most likely positioning of an independant center would also be recorded in ruler units.

     

    Example of an expanded test action:

    RulerUnits.jpg

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points