Skip to main content
Sergiy Kalinkin
Participant
July 24, 2021
Question

Open several RAW files in photoshop as Smart Object Layers

  • July 24, 2021
  • 3 replies
  • 291 views

Hello everyone, 

I am looking for the script or automatade way to open multiple RAW files as smart object layers in one document. 

Currently I have to open raw file as smart object and then "Place/Link Embeded" for additional layers. 

 

Lightroom has option open as layers but it will convert RAW to image.

 

I usually have 30-40 sets of 2-7 layers and it is very annoing to embed so many layers manually.

 

 

 

3 replies

edenb69384871
Participant
April 3, 2025

After struggling away with Chat GPT I made this script that seems to do an alright job of the task:

#target photoshop
app.bringToFront();

(function() {
if (app.documents.length === 0) {
alert("No open document. Please open a document before running the script.");
return;
}

var mainDoc = app.activeDocument;

// RAW file extensions
var rawExtensions = ["CR2", "ARW", "NEF", "DNG", "ORF", "RAF", "PEF"];

// Create the file dialog to only show RAW files
var files = File.openDialog("Select RAW files to place as Smart Objects", "*.cr2;*.arw;*.nef;*.dng;*.orf;*.raf;*.pef", true);

if (!files || files.length === 0) {
alert("No files selected.");
return;
}

// Check that all selected files are RAW
for (var i = 0; i < files.length; i++) {
var ext = files[i].name.split('.').pop().toUpperCase();
if (!rawExtensions.includes(ext)) {
alert("Invalid file type selected. Please select only RAW files.");
return;
}
}

// Disable dialogs for batch processing
var originalDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.NO;

// Process each selected file
for (var i = 0; i < files.length; i++) {
placeAndResizeRawFile(files[i]);
}

// Restore dialogs to original state
app.displayDialogs = originalDialogMode;

// Function to place RAW file as Smart Object and resize it
function placeAndResizeRawFile(file) {
var desc = new ActionDescriptor();
desc.putPath(charIDToTypeID("null"), new File(file)); // Set file path
executeAction(charIDToTypeID("Plc "), desc, DialogModes.NO); // Auto-place without popups

var placedLayer = mainDoc.activeLayer;
fitLayerToCanvas(placedLayer);
}

// Function to resize the placed Smart Object to fit the canvas proportionally
function fitLayerToCanvas(layer) {
var docWidth = mainDoc.width;
var docHeight = mainDoc.height;
var layerBounds = layer.bounds; // Get layer dimensions
 
var layerWidth = layerBounds[2] - layerBounds[0];
var layerHeight = layerBounds[3] - layerBounds[1];

// Calculate scaling factor while preserving aspect ratio
var scaleFactor = Math.min(docWidth / layerWidth, docHeight / layerHeight) * 100;

// Transform the Smart Object
layer.resize(scaleFactor, scaleFactor, AnchorPosition.MIDDLECENTER);
}
})();
edenb69384871
Participant
April 3, 2025

Hi, Also struggling with this, it seems Dr Brown Scripts doesn't work with CC. Is there a modern solution to this problem?

Jeff Arola
Community Expert
Community Expert
April 3, 2025

edenb,

 

What version of Photoshop and operating system are you using?

 

Dr. Brown’s Services 2.3.1 for Adobe Bridge should work in present Photoshop versions.

Sometimes it takes several tries to get it right because the locations for the scripts can be confusing.

 

 

Jeff Arola
Community Expert
Community Expert
July 27, 2021

You can install Dr. Brown’s Services 2.3.1 for Adobe Bridge.

Dr. Brown Scripts

 

Then to select your images in Bridge and go to Tools>Dr. Brown’s Services 2.3.1>Dr Brown's Place-A-Matic.

 

That should place the selected images as smart object layers in photoshop.