Skip to main content
Adobe Photoshop Family

49 Messages

 • 

756 Points

Wed, Feb 12, 2020 12:09 PM

Photoshop: Action to transform placed image to specific pixel dimensions?

I would be grateful to learn from users here how to solve this problem.

I need an Action which will scale a placed image *proportionally* to a specific pixel dimension along one side *regardless of the original size*.

Recording the Transform  to an Action always results in percentages for height and width instead of pixels, which will only work if the originals are the same size, which mine aren’t.

Does anyone here know a way around this?

Responses

18 Messages

 • 

332 Points

8 months ago

I do what I think you are talking about by saving jpg or tiff files in Camera Raw.

49 Messages

 • 

756 Points

Hi Gary, thanks for responding. However, it looks like I didn’t explain my problem very well!

Starting with a blank canvas, I place an image (usually linked rather than embedded). I then want to scale the placed image proportionally to a specific pixel measurement. I mean to scale just the placed image, not the whole canvas.

I would like to save this as an action, but when I've tried recording the transformation as pixels the resulting action is saved as a percentage rather than as the number which I entered into the transform dialog as pixels. Percentages would work if all the source images are the same size but the ones I’m dealing with vary considerably.

44 Messages

 • 

1K Points

have you tried Frames? by default, it scales to fit your image, so if your images are all proportional, they would fit in your frame. You can specify the frame's width and height in pixels. If you have multiple images to do, you could just duplicate the frame and just drag images from Bridge. No need for an action.

49 Messages

 • 

756 Points

Thanks for the suggestion, I hadn’t realised that Photoshop had a frame tool. That could be an alternative workflow.

49 Messages

 • 

756 Points

Thanks Jeff, I’ve just had a look at frames at your suggestion and it actually gets most of the way to what I need. There doesn’t seem to be any fitting rules (such as in InDesign), and the fitting doesn't scale up, only down, but the vast majority of my source images would scale down anyway. I do hundreds of these, so this workflow could save a lot of tedious resizing.

44 Messages

 • 

1K Points

hey Philip, I'm glad it's working. I too was looking for fitting options like InDesign, but there is nothing. I was wondering why you need to do this in the first place though. I've used Lightroom Classic when I have a lot of images that I want to crop and have at the same pixel width. Maybe another workflow for you to checkout.

980 Messages

 • 

16.6K Points

8 months ago

Scaling requires a percentage. You could use a small script which calculated percentage from the image dimensions.

49 Messages

 • 

756 Points

Hi David, thanks for the reply. The transform settings in the options ribbon certainly takes a figure in pixels, I use it every day. The problem is that the pixel figure isn't recorded in the action but converted to a percentage. My hope was that there was a way to insert pixels into the action, but I’ll look at your suggestion of a script (although I have no idea where to start with creating one).

18 Messages

 • 

332 Points

I center images on a white background for printing via image and canvas size tools under Image in Photoshop.  The align tool might be of use to you also.

980 Messages

 • 

16.6K Points

You'll need to do some work on this to pick the right layer and determine long side but this is functional.

layerUpdate();

function layerUpdate(){
    if(documents.length > 0){
        var originalDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.ERROR;
        var originalRulerUnits = preferences.rulerUnits;
        var scale = 0;
        var finished = 1500; //desired size in pixels
        var placed = [];
        try{
            var docRef = activeDocument;
            preferences.rulerUnits = Units.PIXELS;
            var LayerRef = docRef.artLayers[0]; //this gets the top layer
            placed = LayerRef.bounds; //array of four corner coordinates
            scale = (placed[2] - placed[0]); //horizontal size
            scale = finished / scale; //resize factor
            scale = scale * 100;
            LayerRef.resize(scale, scale); //horizontal, vertical percentage
            }
        catch(e){
            alert(e + '  ' + e.line);
            preferences.rulerUnits = originalRulerUnits;
            app.displayDialogs = originalDialogMode;
            return;
            }
        preferences.rulerUnits = originalRulerUnits;
        app.displayDialogs = originalDialogMode;
        }
    else{
        alert('You must have a document open to run this script.');
        return;
        }
    }

49 Messages

 • 

756 Points

Thanks David, that’s very helpful. I have a week or so before the next batch arrives so I have a bit of time to experiment. I’ll let you know how I get on.

127 Messages

 • 

2.3K Points

8 months ago

Could your action open the original image, make the background layer (or all layers if a PSD) a smart object, resize the entire image to meet your pixel scale needs, then copy and paste the smart layer to your working document? (Close the original without saving.)
Some other combination of copying the entire linked layer and pasting into a new document and resizing, before copying back, might prove helpful.

49 Messages

 • 

756 Points

Hi Anthony, thanks for responding. I see what you're getting at but I reckon Jeff’s and David’s suggestions are closer to the sort of workflow I'm looking for.

Champion

 • 

623 Messages

 • 

14.6K Points

7 months ago

If you have a template that has your output sizes updating with linked files, you should definitely have a look at the Asset Generator. Naming your layers with .png or .jpg will let you turn on the generator and have it spit them all out into a sidecar folder automatically rather than needing to export-as. You can even specify scaling, multiple output filetypes, and compression quality in the layer name.
https://helpx.adobe.com/photoshop/using/generate-assets-layers.html

Combined with the script to 'find-replace' text in layers (see below), you can set your templates up with the frame layer named something like 'CLIENTNAME_PRODNAME_1200x600.jpg6' and replace CLIENTNAME and PRODNAME in a few seconds.
https://github.com/Paul-Riggott/PS-Scripts/blob/master/Layer%20Name%20Edit.jsx