Photoshop: Record layer styles in physical units

  • 1
  • Idea
  • Updated 7 years ago
  • (Edited)
Right now Layer layer style setting can only be set using absolute pixel value sizes. This is does not let one record action well for actions can not use logic to retrieve the image pixel size and dpi resolution. An action can easily scale an image to a known width like 8 inches and add canvas size like 1/4" Photoshop will use the current DPI resolution to add the correct number of pixels. However one can not record add a layer style 1/4" for the action recorder has no idea of what Image size set the DPI to to scale the image to 8". So I would like be able to set Layer style setting in a relative pixel size like inches in addtion to absolute pixel size.
Photo of John McAssey

John McAssey

  • 191 Posts
  • 7 Reply Likes

Posted 7 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 812 Reply Likes
Layer styles also record the dpi of the image, and scale themselves on playback or application as a style preset.
Photo of John McAssey

John McAssey

  • 191 Posts
  • 7 Reply Likes
If one records a layer style using 30px it always add 30PX effect so a 300DPI image it is 30/300 1/10" on a 100Dpi image it add 30/100 or 3/10"
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14049 Posts
  • 1735 Reply Likes
You can use scripting to do some condition checking.


// Function for scaling effects. Layer>Layer Style>Scale Effects...
// Proportionally to an expected document size.
function scaleMyEffect(){

// The unit value in pixels of the expected length of the long side of the document
expectedLongSide = 1200;

if (app.activeDocument.height < app.activeDocument.width){// If the doc is Landscape
// Determine the proportion of the active document size compared to the expected document size
scaleEffectsAmount = app.activeDocument.width * 100 / expectedLongSide;
}else{ // If the doc is Portrait
// Determine the proportion of the active document size compared to the expected document size
scaleEffectsAmount = app.activeDocument.height * 100 / expectedLongSide;
}

// Listener code for scaling effects. Layer>Layer Style>Scale Effects...
var idscaleEffectsEvent = stringIDToTypeID( "scaleEffectsEvent" );
var desc35 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
// Put the scaleEffectsAmount in
desc35.putUnitDouble( idScl, idPrc, scaleEffectsAmount );
executeAction( idscaleEffectsEvent, desc35, DialogModes.NO );
}
Photo of John McAssey

John McAssey

  • 191 Posts
  • 7 Reply Likes
Jeff thank you for that code I'll keep it. From reading the code it look like I would need to fit the document I record an action on to 1200x1200 pixels to scale it to a known document size and record the action on it that a add layer style and add the script step which should not scale it for the long side is 1200 px. Then run the recorded action on the original document to test if the layer style look the way it looks on the re-sized document the action was recorded on. Your script may be useful in some cases.
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14049 Posts
  • 1735 Reply Likes
Yup, essentially you use the script to remember the scale of the original document the effects were applied at - Then test the new document's scale and apply an appropriate scaling factor.