I'm dealing with many thousands of psd files containing product images. Most items have been separated from their original background and placed on white. They have a very slight drop shadow to elevate them a bit from the BG. Now I'm overhauling them all (squared images originally but 4:3 needed) and want to give them all the exact same shadow (mainly through recorded actions). I have recorded the shadow in an action (spread of X px, distance of X px etc).

The problem now becomes that image dimensions range from around 1000 up to even 5000 px. And if I apply the same shadow it looks quite different in a smaller image compared with a larger one.

What I'm looking for is a way to create shadow not with PIXEL distance, spread etc but with PERCENT distance etc. This way I'm hoping to achieve the same APPARENT shadow in all images. I have worked with PS for many years and searched online but never came across anything like that.

Is there a way to achieve this? Any help would be appreciated.

  • 2
    Why don't you create the action to resize the image to a set size and then apply the drop shadow? – WELZ Aug 27 '18 at 14:21
  • I thought of this. But I don't want to downscale the original (which is supposed to be kept archived). Converting everything to a smart object would add considerable time to the process (as would the downscaling). – Engle Aug 27 '18 at 14:25
  • If you backup up your original files, you can do as WELZ says and still have the originals archived. – Invariant Change Aug 27 '18 at 15:12
  • that's true, hadn't thought of this :) If I set up the right actions, I can even reproduce this for single images later. Anyhow, wouldn't this be a cool addition to PS in the future? ;) – Engle Aug 27 '18 at 15:51

Here's how I'd approach this with scripting. First I define reference shadow and reference size, then if image width isn't the same as reference size, I linearly transform shadow values based on ratio of current image width and reference width.

Result (first image is reference, 1000x1000, second is 2000x2000, third is 660x600, fourth is 200x200):

enter image description here

Because Photoshop doesn't support decimals in the shadow effect, the results between won't be exactly the same, but close enough.

So you can add this script as one of the action steps:

function main()

    var myShadow = {
                r: 0,
                g: 0,
                b: 0,
            opacity: 80,
            angle: 120,
            distance: 10,
            spread: 0,
            size: 20,
        referenceSize = 1000,
        doc = activeDocument,
        w = doc.width.as("px"),
        h = doc.height.as("px");

    if (w != referenceSize)
        var ratio = w/referenceSize;
        myShadow.distance = linear(ratio,0,1,0,myShadow.distance);
        myShadow.spread = linear(ratio,0,1,0,myShadow.spread);
        myShadow.size = linear(ratio,0,1,0,myShadow.size);



    function dropShadow(shadow)
        var desc10 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putProperty(cTID('Prpr'), cTID('Lefx'));
        ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
        desc10.putReference(cTID('null'), ref1);
        var desc11 = new ActionDescriptor();
        desc11.putUnitDouble(cTID('Scl '), cTID('#Prc'), 100);
        var desc12 = new ActionDescriptor();
        desc12.putBoolean(cTID('enab'), true);
        desc12.putBoolean(sTID('present'), true);
        desc12.putBoolean(sTID('showInDialog'), true);
        desc12.putEnumerated(cTID('Md  '), cTID('BlnM'), cTID('Nrml'));
        var desc13 = new ActionDescriptor();
        desc13.putDouble(cTID('Rd  '), shadow.color.r);
        desc13.putDouble(cTID('Grn '), shadow.color.g);
        desc13.putDouble(cTID('Bl  '), shadow.color.b);
        desc12.putObject(cTID('Clr '), cTID('RGBC'), desc13);
        desc12.putUnitDouble(cTID('Opct'), cTID('#Prc'), shadow.opacity);
        desc12.putBoolean(cTID('uglg'), false);
        desc12.putUnitDouble(cTID('lagl'), cTID('#Ang'), shadow.angle);
        desc12.putUnitDouble(cTID('Dstn'), cTID('#Pxl'), shadow.distance);
        desc12.putUnitDouble(cTID('Ckmt'), cTID('#Pxl'), shadow.spread);
        desc12.putUnitDouble(cTID('blur'), cTID('#Pxl'), shadow.size);
        desc12.putUnitDouble(cTID('Nose'), cTID('#Prc'), 0.000000);
        desc12.putBoolean(cTID('AntA'), false);
        var desc14 = new ActionDescriptor();
        desc14.putString(cTID('Nm  '), "Linear");
        desc12.putObject(cTID('TrnS'), cTID('ShpC'), desc14);
        desc12.putBoolean(sTID('layerConceals'), true);
        desc11.putObject(cTID('DrSh'), cTID('DrSh'), desc12);
        desc10.putObject(cTID('T   '), cTID('Lefx'), desc11);
        executeAction(cTID('setd'), desc10, DialogModes.NO);

    function linear(X, A, B, C, D, _cut)
        var _cut = _cut !== undefined ? _cut : false;
        var Y = (X - A) / (B - A) * (D - C) + C
        if (_cut)
            Y > D && Y = D;
            Y < C && Y = C;
        return Y

    function cTID(s)
        return app.charIDToTypeID(s);

    function sTID(s)
        return app.stringIDToTypeID(s);

app.activeDocument.suspendHistory("addShadow", "main()");
| improve this answer | |
  • this is a great approach! I need to get into scripting more! This would do what I want at any size. I will try it out tomorrow (my timezone goes to sleep soon) but mark it as answer already :) – Engle Aug 27 '18 at 15:56
  • couldn't wait. ;) this is what I was looking for. Awesome! As a sidenote: this adds the shadow and replaces previous (different) layer effects. This is fine in my case, just to let others know. Thanks – Engle Aug 27 '18 at 16:09
  • Yes, this method replaces existing effects. There're several ways to avoid this behaviour, the easiest probably will be to group layers first (which may work or not depending on layout and effects) – Sergey Kritskiy Aug 27 '18 at 19:02

Maybe going back to the old times when making a drop shadow wasn't a layer effect.

With the image selection active:

The action:

  • Select Layer "Background"
  • Make a fill layer > Black, 100%
  • Transform current layer > Using the top-middle transform point, scale 102% vertically and horizontally.
  • Select mask channel
  • Gaussian blur > 10px
  • Set current layer > Mode= multiply
  • Set current layer > Opacity= 35%

The circle is a 1000 X 1000 file

enter image description here

The rectangle is a 5000 X 600 file

enter image description here

| improve this answer | |
  • This is no different from adding drop shadow a as a layer style. – Joonas Aug 27 '18 at 15:19
  • 1
    The difference is the shadow displacement that is not by pixels but by the percentage of scaling of the figure. The only one pixel measurement is the blur. – user120647 Aug 27 '18 at 15:24
  • Author mentioned he uses Shadow Distance, this approach unfortunately will work only with simple shapes and with a shadow directly under the layer I guess – Sergey Kritskiy Aug 27 '18 at 15:34
  • 1
    Sorry I missed that. This however doesn't change the fact that shadow won't be the same as drop shadow and effect will be more strong on the opposite corner prntscr.com/kngzxe But that's a particular case. Sorry for nitpicking, a terrible habit – Sergey Kritskiy Aug 27 '18 at 16:12
  • 1
    Don't worry, i'm kind of used to this. It's a very common behavior here. – user120647 Aug 27 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.