
Stephen Marsh
Community Expert
Stephen Marsh
Community Expert
Activity
4 hours ago
I'm trying to put 2 portrait photos into one image. How do I do it in photoshop. See e.g. It's for real estate agents
By @kim28649024vtu1
If this is something that you wish to automate for multiple/many images, then you will need a script to process sets of 2 images at a time and then "do something" with the 2 open images before saving, closing and moving on to the next pair. Such a script can be found here:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-automate-load-files-into-stack/m-p/13499068#U14928257
The following variation is for 2 separate input folders, rather than a single input folder:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-open-files-and-layer-them/m-p/12532657#U14933502
Alternatively, if you prefer to work semi-automatically but don't want to keep track of the files to open and work on, the following script can work through a source folder and keep track of the open/closed files for you.
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-open-a-number-of-images-but-one-at-a-time/m-p/13804564#U14972022
These three scripts can run an action on the set of open images, this is where you would record the extra steps to adjust canvas size, move the active upper layer to the right etc.
... View more
5 hours ago
1 Upvote
I think your post Is getting lost in translation to English. Please feel free to write in your native language and let the forum use translation software. Perhaps you provide numbered step by step information to break down a complex topic into easier parts?
... View more
11 hours ago
It will be a right-facing closing brace:
}
I'm not in front of a computer to test, I'll do so later if no one else has commented on what line to add it.
... View more
16 hours ago
1 Upvote
You're welcome. If this is part of a larger script, I would have assumed that you would know if a previous step edited a smart object, but if this was the case, you wouldn't have asked. Glad to be of assistance.
... View more
Community Expert
in Photoshop ecosystem Discussions
‎Mar 29, 2025
03:46 PM
2 Upvotes
‎Mar 29, 2025
03:46 PM
2 Upvotes
Yes, exactly, embedded only.
By @dendenis82
Please try the following and let me know how you go:
/*
Check Test If The Active Document Is An Embedded Smart Object.jsx
Stephen Marsh
v1.0 - 30th March 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/extendscript-to-detect-is-current-document-standalone-document-or-smart-object-in-editing-mode/td-p/15239239
*/
checkForEmbeddedSO();
function checkForEmbeddedSO() {
try {
var fullPath = app.activeDocument.fullName.toString();
var winRegex = /\/Temp\//;
var macRegex = /^\/private\/var\/folders\//;
var trueString = "The active document appears to be an embedded smart object.";
if (winRegex.test(fullPath)) {
alert(trueString);
} else if (macRegex.test(fullPath)) {
alert(trueString);
} else {
alert("The active document does not appear to be an embedded smart object.");
}
} catch (error) {
alert("Error: " + error.message);
}
}
... View more
‎Mar 29, 2025
02:52 PM
@Stephen Marsh
Also, someone recommended that I do this for my QR codes. Is this a possible option?
I've already posted the best format, but take your image (ideally, high resolution), convert to grayscale, then convert to bitmap mode using 50% threshold, save as LZW-compressed TIFF. This will be black only and the white areas will be transparent if you desire. The TIFF can be colored in InDesign if desired (as long as you have correct contrast between code and background). If you have a number of these, you can create a batch process in Photoshop.
By @Mateomono
That is also a viable approach and will create much smaller file sizes than working with CMYK 8bpc data. Run with that!
... View more
‎Mar 29, 2025
02:47 PM
@Stephen Marsh  
Also, your explanation from before was clear, but somehow I’m struggling with the last steps. How does it turn into 100K black after pasting it? Are there any tutorials you would recommend on this?
By @Mateomono
The copied data is black, so if you paste it into the targeted/selected active black channel of a white filled CMYK mode file the same pixel dimensions as the original the data will be K only.
... View more
‎Mar 29, 2025
02:43 PM
Do you know that such size codes can be successfully read? What print method is being used (offset lithography, digital toner laser printer, inkjet printer etc).
The 1400+ resolution should be fine at that size as long as the code isn't scaled larger than 36mm in layout software or resampled when making a PDF from layout or processing at the RIP/DFE.
... View more
‎Mar 29, 2025
02:26 PM
@dendenis82 - Can it be assumed that you are only dealing with embedded smart objects and not linked or generative?
... View more
‎Mar 29, 2025
02:15 PM
I don't use LrC, I'd expect the presets applied in LrC would travel as CRS metadata into Photoshop and are then available in ACR as applied settings (not as a preset). I guess from your post that this isn't the case.
AFAIK, ACR is generally outside of scripting.
... View more
‎Mar 29, 2025
04:27 AM
@Stephen MarshThank you for the explanation! Great, then I will do that, and it should fix my issue. One question I still have—would it be wise to consider image tracing the PNG in Illustrator so that it becomes a vector and can easily be changed to 100K black?
By @Mateomono
I wouldn't do so.
What is the final reproduction size that the QR code will be printed?
For example, let's say that it's 1 inch.
In Photoshop, go to Image > Image Size and uncheck "Resample Image" and change the size to 1 inch. What is the effective resolution of the image at this size? Most lineart would be expected to have 600 ppi or higher resolution, however, this is more critical for diagonals or curves than horizontal and vertical edges.
If your QR code only contains horizontal and vertical pixels, then it should be pure solid black with no shades of gray; you don't want a fuzzy, screened edge when printed. You can always apply a 50% threshold adjustment to the image to force it to pure white/black.
For such art, the only appropriate upscaling is using Nearest Neighbour resampling/interpolation to preserve the original pixel structure, using even multiples of the original resolution or pixel count, so 200% or if the original image was 866 px wide then resample to 1732 px wide etc.
... View more
‎Mar 29, 2025
02:48 AM
@D FosseSo, I would need to convert it to CMYK in Photoshop?
By @Mateomono
Yes, but more work than that would be required. There are many valid variations on the following steps to get to a 0cmy100k QR code:
Select any of the R, G or B channels and copy it to the clipboard.
Convert to CMYK mode.
Fill the image with white, deleting everything.
Select the K channel.
Paste in the clipboard content.
You will then get something like this:
You can record these steps into an action and use it on multiple images from the action or running the action via the Batch command or Image Processor script etc.
... View more
Community Expert
in Photoshop ecosystem Discussions
‎Mar 28, 2025
04:53 PM
1 Upvote
‎Mar 28, 2025
04:53 PM
1 Upvote
@harris_7195 – If it is ONLY the Lightness value that has to increment for each new chart, that would be much easier to script as this is a constant value for all of the patches.
Starting from your vector layer based chart, working on a duplicate file where it has been flattened, you can use channel operations to apply one channel to another in various blend modes and opacity, or use linear adjustments such as Brightness/Contrast set to legacy mode.
... View more
Community Expert
in Photoshop ecosystem Discussions
‎Mar 28, 2025
04:49 PM
1 Upvote
‎Mar 28, 2025
04:49 PM
1 Upvote
I'm hoping some of the other scripting regulars chime in...
The first challenge that I see is in selecting each layer in the appropriate order to apply the adjustment to the base colour.
They are not named uniquely; they all have the same name of Rectangle 1. If there was a logical and consistent pattern with a unique layer name or static Layer ID, a script could loop over the layers using the Layer ID order to select the next layer.
Here are labels on your current objects to help explain what I mean:
That being said, I'm still trying to work out if that would be starting from the centre "parent" square, or from the upper left square or somewhere else.
This would require creating each rectangle in the required order to produce the required static Layer ID.
But perhaps there'a a better way...
... View more
‎Mar 28, 2025
03:30 AM
@punit_9859
Back to the drawing board. Reflecting on the challenges and your feedback, I think that it is best and safest to process files 200 inches or larger manually. I have replaced the previous 2.0 code with the new v2.1 code as it wasn't performing as expected.
I'm going to have to take a break on this, good luck!
... View more
‎Mar 27, 2025
10:52 PM
Are all of the files from the same source, Adobe Illustrator?
Why do you need to rasterize?
Have you tried rasterizing the PDF in either Illustrator or Acrobat Pro?
... View more
‎Mar 27, 2025
07:40 PM
Nice! You could also use generate assets, but we digress from the original point of how silly a 7-step quality slider is 🙂
By @jonathan8_8
Forgive me for being pragmatic and trying to help. :]
Adobe introduced this for whatever reason when they created Export As/Quick Export and it is what it is I'm afraid. They are aware that it isn't loved by end users. Export As is an unfinished project as far as I'm concerned as it stands, let alone throwing out the entire JPEG export code and starting from scratch again.
... View more
‎Mar 27, 2025
06:03 PM
1 Upvote
That's a pretty generic answer, can you be more specific? Where in settings?
By @johnm71918526
Preferences/Settings > Image processing > Select Subject and Remove Background
... View more
‎Mar 27, 2025
05:55 PM
The legacy save for web is the only saving grace, but unfortunate that it doesnt work with multiple artboards.
@jonathan8_8 – Have you tried turning off the visibility of the other artboards before using Save for Web (Legacy)? I mean sure… but the whole point is to export multiple at once. It's fine… we're all in figma now anyway haha
Agreed, however, knowing that this is the answer, this can be scripted for all artboards. I hit some issues (bugs?) so this isn't perfect, but it's certainly usable:
/*
All Artboards Interactive JPEG Save for Web.jsx
Stephen Marsh
v1.0 - 28th March 2025
https://community.adobe.com/t5/photoshop-ecosystem-ideas/p-bring-back-jpeg-quality-percentage-to-export-as-dialog/idc-p/14446391/page/5#U15236123
*/
#target photoshop
try {
var outputFolder = Folder.selectDialog("Select a folder to save the output files");
if (outputFolder) {
alert("Remember to paste the artboard name from the clipboard to the file name to replace the default 'artboards' save name each time!");
processLayerSets(outputFolder);
app.refresh();
alert("Restore or hide/restore the visibility of any artboards which are not previewing correctly after the script has finished.");
} else {
alert("No folder selected. Script aborted!");
}
} catch (e) {
alert("Error: " + e);
}
function processLayerSets(outputFolder) {
var doc = app.activeDocument;
if (doc.layerSets.length == 0) {
alert("No layer sets found in the document!");
return;
}
for (var i = 0; i < doc.layerSets.length; i++) {
var currentLayerSet = doc.layerSets[i];
// Hide all layer sets
for (var j = 0; j < doc.layerSets.length; j++) {
doc.layerSets[j].visible = false;
}
// Make current layer set visible
currentLayerSet.visible = true;
// Select the current layer set (make it active)
doc.activeLayer = currentLayerSet;
// Get the name of the current (now active) layer set
var artboardName = currentLayerSet.name;
// Copy the artboard name to the clipboard
var d = new ActionDescriptor();
d.putString(stringIDToTypeID("textData"), artboardName);
executeAction(stringIDToTypeID("textToClipboard"), d, DialogModes.NO);
// Export the current layer set as a JPG file
exportSaveForWeb(true, new File(outputFolder + '/' + artboardName + '.jpg'), false, 75);
}
}
function exportSaveForWeb(DIDr, in2, interfaceIconFrameDimmed, quality) {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor14 = new ActionDescriptor();
descriptor14.putEnumerated(c2t("Op "), c2t("SWOp"), c2t("OpSa"));
descriptor14.putBoolean(c2t("DIDr"), DIDr);
descriptor14.putPath(s2t("in"), in2);
descriptor14.putEnumerated(s2t("format"), c2t("IRFm"), s2t("JPEG"));
descriptor14.putBoolean(s2t("interfaceIconFrameDimmed"), interfaceIconFrameDimmed);
descriptor14.putInteger(s2t("quality"), quality);
descriptor.putObject(s2t("using"), s2t("SaveForWeb"), descriptor14);
executeAction(s2t("export"), descriptor, DialogModes.ALL);
}
Copy the code text to the clipboard
Open a new blank file in a plain-text editor (not in a word processor)
Paste the code in
Save as a plain text format file – .txt
Rename the saved file extension from .txt to .jsx
Install or browse to the .jsx file to run (see below)
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
... View more
‎Mar 27, 2025
04:18 PM
The legacy save for web is the only saving grace, but unfortunate that it doesnt work with multiple artboards.
@jonathan8_8 – Have you tried turning off the visibility of the other artboards before using Save for Web (Legacy)?
... View more
Community Expert
in Photoshop ecosystem Discussions
‎Mar 27, 2025
04:08 PM
1 Upvote
‎Mar 27, 2025
04:08 PM
1 Upvote
This would require a script in either Bridge or Photoshop or Lightroom to identify the parent folder and process based on that information. I would batch this from Bridge. An Action can call a script which would parse the path, identify the folder, and process with the correct action.
In the example Photoshop script snippet below, you could use multiple if-then clauses or better yet, a case statement for the path.
(Please test/verify this, my regex foo isn't great)
var docRef = app.activeDocument; //frontmost document
var p = docRef.path.toString(); //path to docRef
p = p.replace(/^.+\//, ''); //regex to replace everything before the final /
if(p == 'Group 1')){ //check result
doAction('myAction', 'Set 1'); //run action
}
By @ExUSA
Nice one!
There is an extra closing parentheses on the if statement, which breaks the conditional.
Also, we need to handle URI encoding of spaces %20 either using either .fsName or decodeURI()
try {
var docRef = app.activeDocument; //frontmost document
var p = docRef.path.fsName.toString(); //path to docRef using file system naming
p = p.replace(/^.+\//, ''); //regex to replace everything before the final /
if (p == 'Group 1') { //check result
doAction('myAction', 'Set 1'); //run action
}
}
catch(e) {
alert(e);
}
try {
var docRef = app.activeDocument; // Get the active document
var p = decodeURI(docRef.path); // Decode URI to get the path
p = p.replace(/^.+\//, ''); // Extract the last part of the path using regex
if (p == 'Group 1') { // Check if the extracted part matches
doAction('myAction', 'Set 1'); // Run the specified action
}
}
catch (e) {
alert(e);
}
... View more
‎Mar 27, 2025
03:57 PM
I see Adobe making their own AI keywording software before leveraging third parties, but that's just my personal view.
... View more
‎Mar 27, 2025
01:32 PM
I'm pretty sure that I created a script to run actions based on folder names, I'll see if I can dig it up.
EDIT: Turns out if was for filenames, not folders... But it should be easy enough to change.
https://community.adobe.com/t5/photoshop/script-to-place-logos-in-diffrent-phones-cases-in-photshop/m-p/11098559
... View more
‎Mar 27, 2025
01:29 PM
@Eyecapture
Thanks, you're welcome!
Multiple valid regular expressions can be used, that was just one example.
Also, using basic Mac or Windows commands, it is possible to rename files by first using a spreadsheet to split the source names on spaces to columns, then combine using a formula into the command to copy/paste into the command prompt.
There are also scripts to batch rename from a spreadsheet source.
... View more
‎Mar 27, 2025
05:23 AM
@punit_9859
This v2 script uses a different method to get the PDF page size, it works with your sample PDF but fails with some other PDF files that lack the required information. If you get an error that the page size can't be determined, use the previous v1 script.
I hope to rework this, but it will have to do for now:
Back to the drawing board. Reflecting on the challenges and your feedback, I think that it is best and safest to process files 200 inches or larger manually. I have replaced the previous 2.0 code with the new v2.1 code as it wasn't performing as expected.
/*
Rasterize to Variable Resolution Based on PDF Page Size in Inches.jsx
Stephen Marsh
v2.1, 26th March 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/need-help-in-scripting/td-p/15232063
*/
#target photoshop
// Open a dialog to select the PDF file
var thePDF = File.openDialog("Select a PDF file to rasterize");
if (thePDF !== null) {
// Get the file dimensions
var pdfOpenOptions = new PDFOpenOptions();
pdfOpenOptions.antiAlias = true;
pdfOpenOptions.mode = OpenDocumentMode.GRAYSCALE; // Set to grayscale for speed
pdfOpenOptions.resolution = 2; // Low res for speed
pdfOpenOptions.page = 1; // First page only
pdfOpenOptions.cropPage = CropToType.MEDIABOX; // MEDIABOX | CROPBOX | BLEEDBOX | TRIMBOX | ARTBOX
app.open(thePDF, pdfOpenOptions);
// Get the doc width and height in inches
var docWidthInches = (app.activeDocument.width.as("inches")).toFixed(2);
var docHeightInches = (app.activeDocument.height.as("inches")).toFixed(2);
// Close the doc without saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// Determine the greater value between width and height
var maxDimensionInches = Math.max(docWidthInches, docHeightInches);
// Set the resolution based on the greater value
var resolution;
if (maxDimensionInches <= 12) {
resolution = 600;
} else if (maxDimensionInches >= 12.01 && maxDimensionInches <= 24) {
resolution = 300;
} else if (maxDimensionInches >= 24.01 && maxDimensionInches <= 120) {
resolution = 125;
} else if (maxDimensionInches <= 199.99) {
resolution = 72;
} else {
alert("Process this oversize PDF manually.");
throw new Error("Process this oversize PDF manually.");
}
// Re-open the PDF as a new doc in RGB mode with the determined resolution
pdfOpenOptions.mode = OpenDocumentMode.RGB;
pdfOpenOptions.resolution = resolution;
app.open(thePDF, pdfOpenOptions);
// Flatten the image to remove transparency and layers
app.activeDocument.flatten();
/*
// New layer from Background
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("layer"), s2t("background"));
descriptor.putReference(s2t("null"), reference);
descriptor.putObject(s2t("to"), s2t("layer"), descriptor2);
executeAction(s2t("set"), descriptor, DialogModes.NO);
*/
} else {
alert("Script cancelled!");
}
... View more
‎Mar 27, 2025
01:37 AM
For PDF files larger than 200 inches, the Photoshop interface will default to 200 and you will have to manually override this with the desired width, such as 272 in @ 72 ppi. Scripting will have the same limitation with the current script code. I'll see if I can find another workable alternative solution, as my first idea also hits the limit of 200, although it can be made larger if the required size is known.
... View more
‎Mar 26, 2025
11:12 PM
Scripts can't change how Photoshop works, what it's limitations are.
I have an alternative method which might work for these large dimensions. I'll come back to you when I have time.
... View more
‎Mar 26, 2025
10:13 PM
@punit_9859 – Try this script and let me know how you go:
/*
Rasterize to Variable Resolution Based on PDF Page Size in Inches.jsx
Stephen Marsh
v1.0, 26th March 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/need-help-in-scripting/td-p/15232063
*/
#target photoshop
// Open a dialog to select the PDF file
var thePDF = File.openDialog("Select a PDF file to rasterize");
if (thePDF !== null) {
// Get the file dimensions
var pdfOpenOptions = new PDFOpenOptions();
pdfOpenOptions.antiAlias = true;
pdfOpenOptions.mode = OpenDocumentMode.GRAYSCALE; // Set to grayscale for speed
pdfOpenOptions.resolution = 2; // Low res for speed
pdfOpenOptions.page = 1; // First page only
pdfOpenOptions.cropPage = CropToType.MEDIABOX; // MEDIABOX | CROPBOX | BLEEDBOX | TRIMBOX | ARTBOX
app.open(thePDF, pdfOpenOptions);
// Get the doc width and height in inches
var docWidthInches = (app.activeDocument.width.as("inches")).toFixed(2);
var docHeightInches = (app.activeDocument.height.as("inches")).toFixed(2);
// Close the doc without saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// Determine the greater value between width and height
var maxDimensionInches = Math.max(docWidthInches, docHeightInches);
// Set the resolution based on the greater value
var resolution;
if (maxDimensionInches < 12) {
resolution = 600;
} else if (maxDimensionInches >= 12.01 && maxDimensionInches <= 24) {
resolution = 300;
} else if (maxDimensionInches >= 24.01 && maxDimensionInches <= 120) {
resolution = 125;
} else {
resolution = 72;
}
// Re-open the PDF as a new doc in RGB mode with the determined resolution
pdfOpenOptions.mode = OpenDocumentMode.RGB;
pdfOpenOptions.resolution = resolution;
app.open(thePDF, pdfOpenOptions);
// Flatten the image to remove transparency and layers
app.activeDocument.flatten();
/*
// New layer from Background
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("layer"), s2t("background"));
descriptor.putReference(s2t("null"), reference);
descriptor.putObject(s2t("to"), s2t("layer"), descriptor2);
executeAction(s2t("set"), descriptor, DialogModes.NO);
*/
} else {
alert("Script cancelled!");
}
Copy the code text to the clipboard
Open a new blank file in a plain-text editor (not in a word processor)
Paste the code in
Save as a plain text format file – .txt
Rename the saved file extension from .txt to .jsx
Install or browse to the .jsx file to run (see below)
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
... View more
‎Mar 26, 2025
05:12 PM
2 Upvotes
The Regular Expression find/replace:
Find:
^([^_]+)_([^_]+)_.*$
Replace:
$2, $1
Using Bridge's Batch Rename tool with the String Substitution Regular Expression option:
... View more
Community Expert
in Photoshop ecosystem Discussions
‎Mar 26, 2025
04:55 PM
1 Upvote
‎Mar 26, 2025
04:55 PM
1 Upvote
Although the title "Prompt Engineer" is often met with derision, it can't be denied that how you "craft" your input has a huge effect on the output of a LLM.
Put another way, results depend on what you type in (to various degrees).
... View more