Skip to main content
Inspiring
February 9, 2017
Answered

ActiveDocument.resizeImage doesn't resize layer effects

  • February 9, 2017
  • 2 replies
  • 1922 views

I noticed something when I made a script for batch-exporting a large number of icons:

When I scale things manually (Image > Image Size), the layer effects of my artLayers scale accordingly to the document size.

When I scale things in code, the layer effects are NOT scaled accordingly to the document size. So if I scale something down then the layer effect will appear to be twice as thick/strong as before - why?

You can try it yourself:

Create a doc, with a new layer, paint something like a square and apply a stroke layer effect to it of something like 8px.

Run the below code:

var doc = activeDocument

doc.resizeImage(UnitValue(50, "percent"), UnitValue(50, "percent"), 72, ResampleMethod.BILINEAR);

The layer will still have a 8px thick stroke effect. But if you scale it manually the effect will scale along with the document.
How can I repeat that behavior in code?

This topic has been closed for replies.
Correct answer SuperMerlin

You could use AM code...

function resizeWithScale(Percent) {

var desc42 = new ActionDescriptor();

desc42.putUnitDouble( charIDToTypeID('Wdth'), charIDToTypeID('#Prc'), Percent );

desc42.putBoolean( stringIDToTypeID('scaleStyles'), true );

desc42.putBoolean( charIDToTypeID('CnsP'), true );

desc42.putEnumerated( charIDToTypeID('Intr'), charIDToTypeID('Intp'), stringIDToTypeID('bicubicAutomatic') );

executeAction( charIDToTypeID('ImgS'), desc42, DialogModes.NO );

};

resizeWithScale(50);

2 replies

HeimdaalAuthor
Inspiring
February 10, 2017

Well I guess that's how I have to work to get around this inconsistency. Thanks!

JJMack
Community Expert
Community Expert
February 10, 2017

What inconsistency? Scaling styles has always been an option and feature as far as I can remember?  In Image  resize a setting option and an option in menu layer>layer styles>scale effects....

JJMack
HeimdaalAuthor
Inspiring
February 11, 2017

That is on by default
You cannot change that setting in code (DOM)
Therefore scaling manually VS scaling in code = Different results = Inconsistent

SuperMerlin
SuperMerlinCorrect answer
Inspiring
February 10, 2017

You could use AM code...

function resizeWithScale(Percent) {

var desc42 = new ActionDescriptor();

desc42.putUnitDouble( charIDToTypeID('Wdth'), charIDToTypeID('#Prc'), Percent );

desc42.putBoolean( stringIDToTypeID('scaleStyles'), true );

desc42.putBoolean( charIDToTypeID('CnsP'), true );

desc42.putEnumerated( charIDToTypeID('Intr'), charIDToTypeID('Intp'), stringIDToTypeID('bicubicAutomatic') );

executeAction( charIDToTypeID('ImgS'), desc42, DialogModes.NO );

};

resizeWithScale(50);