Copy link to clipboard
Copied
Hello.
The script available here doesn't work. https://community.adobe.com/t5/photoshop/import-images-to-artboards/m-p/8430829
Does anyone have a working solution?
I have 60 images in one folder and I need each to be Artboard, not layer.
And also there is no way to convert all jpg files in one folder to png with photoshop? I tried action but it just gives me psb or jpg again.
Copy link to clipboard
Copied
This quick hack to the original code should work for flattened originals:
/*
Import images to artboards?
https://community.adobe.com/t5/photoshop/import-images-to-artboards/m-p/8430829
Import multiple PNG and JPG files as individual Artboards
https://community.adobe.com/t5/photoshop/import-multiple-png-and-jpg-files-as-individual-artboards/td-p/12125092
*/
// filesToArtboards.jsx - Adobe Photoshop Script
// Version: Modified 2021, Flattened Originals
// Requirements: Adobe Photoshop CC 2015, or higher
// Author: Anton Lyubushkin (nvkz.nemo@gmail.com)
// Website: http://lyubushkin.pro/
// ============================================================================
// Installation:
// 1. Place script in:
// PC: C:\Program Files\Adobe\Adobe Photoshop CC#\Presets\Scripts\
// Mac: <hard drive>/Applications/Adobe Photoshop CC#/Presets/Scripts/
// 2. Restart Photoshop
// 3. Choose File > Scripts > filesToArtboards
// ============================================================================
#target photoshop
app.bringToFront();
// Save the current ruler units and set to pixels
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
function cTID(s) {
return app.charIDToTypeID(s);
}
function sTID(s) {
return app.stringIDToTypeID(s);
}
function newArtboard(_name, _w, _h) {
var desc6 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(sTID('artboardSection'));
desc6.putReference(cTID('null'), ref1);
var desc7 = new ActionDescriptor();
desc7.putString(cTID('Nm '), _name);
desc6.putObject(cTID('Usng'), sTID('artboardSection'), desc7);
var desc8 = new ActionDescriptor();
desc8.putDouble(cTID('Top '), 0);
desc8.putDouble(cTID('Left'), 0);
desc8.putDouble(cTID('Btom'), _h);
desc8.putDouble(cTID('Rght'), _w);
desc6.putObject(sTID('artboardRect'), sTID('classFloatRect'), desc8);
executeAction(cTID('Mk '), desc6, DialogModes.NO);
}
function main() {
var fileList = app.openDialog("Select your files"),
delta = 0,
currentDocWidth = 0;
if (fileList != null && fileList != "") {
var doc = app.documents.add(400, 400, 72, "File1");
for (var i = 0; i < fileList.length; i++) {
app.open(fileList[i]);
var idset = stringIDToTypeID("set");
var desc914 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref474 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
var idbackground = stringIDToTypeID("background");
ref474.putProperty(idlayer, idbackground);
desc914.putReference(idnull, ref474);
var idto = stringIDToTypeID("to");
var desc915 = new ActionDescriptor();
var idlayer = stringIDToTypeID("layer");
desc914.putObject(idto, idlayer, desc915);
executeAction(idset, desc914, DialogModes.NO);
currentDocWidth = app.activeDocument.width.value;
newArtboard(app.activeDocument.name, app.activeDocument.width.value, app.activeDocument.height.value);
app.activeDocument.activeLayer.duplicate(doc, ElementPlacement.INSIDE);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
if (i > 0) {
app.activeDocument.activeLayer.translate(delta, 0);
}
delta2 = delta + currentDocWidth;
}
app.runMenuItem(charIDToTypeID("FtOn"));
var iddelete = stringIDToTypeID("delete");
var desc733 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref395 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
ref395.putName(idlayer, "Layer 0");
desc733.putReference(idnull, ref395);
var idlayerID = stringIDToTypeID("layerID");
var list44 = new ActionList();
list44.putInteger(5);
desc733.putList(idlayerID, list44);
executeAction(iddelete, desc733, DialogModes.NO);
alert('Done!');
}
}
main();
// Restore the ruler units
app.preferences.rulerUnits = savedRuler;
P.S. The original code didn't specify ruler units (it probably assumed px) and would silently fail with rulers set to percent.
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Error. And thank you if you manage to fix this. I have 60 JPG and PNG that I need to use as masks in artboards, I can't do this by hand....
Copy link to clipboard
Copied
What version of Photoshop are you using?
What platform, Mac or Win?
Are you making any changes to the code?
Do you have 113 lines of code when you copy/paste from the code block above?
I can't comment on why you are getting that error, it works for me on CC2021 Mac Big Sur 11.4.
Copy link to clipboard
Copied
What version of Photoshop are you using? Latest 2021, I updates last week.
What platform, Mac or Win? Win 10 Pro
Are you making any changes to the code? No, I have no idea what is that. I copy-paste in notepad, saved as jsx or something that is needed, placed it under scripts and then run it from the Program
Do you have 113 lines of code when you copy/paste from the code block above? No only 90, I thought the code starts at #target photoshop and the above are just instructions. #facepalm
Now I get this error: Error 8800: General Photoshop error occurred. This
functionality may not be available in this version of
Photoshop.
- The command "Set" is not currently available.
Line: 77
-> executeAction(idset, desc914, DialogModes.NO);
I can't comment on why you are getting that error, it works for me on CC2021 Mac Big Sur 11.4.
Copy link to clipboard
Copied
I was trying to track the reported error in my code copy, which is 113 lines of code, vs. your abbreviated code copy of 90 lines. Obviously this makes things harder to find, as the lines are offset.
Perhaps the commercial version will help you:
https://exchange.adobe.com/creativecloud.details.15995.uberimport.html
It's only $5
Copy link to clipboard
Copied
I copied the entire code before last message, it has 113 lines and that last message I made has the error I get.
Error 8800: General Photoshop error occurred. This
functionality may not be available in this version of
Photoshop.
- The command "Set" is not currently available.
Line: 77
-> executeAction(idset, desc914, DialogModes.NO);
I will try to reinstall.
Copy link to clipboard
Copied
As a proof of concept. Please review the following layer panel screenshot:
There were 4 separate input images. This could be 40 or 400 etc.
In this case, they are all the same pixel dimensions.
All 4 input files have all been stacked one on top of the other, each file as a separate artboard.
Is this what you are looking for?
If so, I have a different scripted solution that I just hacked from another script.
Is this worth persuing?
What about the artboard names? What about the layer names? What else don't I know, that I should know about this project if I do decide to invest my time into developing this further?
// Stephen Marsh
#target photoshop
if (app.documents.length === 0) {
(function () {
// Capture original ruler units and set ruler units to pixels
var origUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// Open the input folder
var inFolder = Folder.selectDialog('Please select the input folder:');
// Test if Cancel button returns null, then do nothing
if (inFolder === null) {
app.beep();
return;
}
// Supported file formats
var remainingFiles = inFolder.getFiles(/\.(jpg|png)$/i);
// Alpha numeric sort
remainingFiles.sort();
// Process the first file
var firstFile = app.open(File(remainingFiles[0]));
app.activeDocument.duplicate("Artboard Stack from Files", false);
firstFile.close(SaveOptions.DONOTSAVECHANGES);
var artboardStack = app.activeDocument;
app.activeDocument = artboardStack;
// Rename the duped layer back to "Background"
artboardStack.activeLayer.name = "Background";
// Call the artboard function
artBoardFromLayers();
// Process the remaining files
for (var i = 1; i < remainingFiles.length; i++) {
var openFiles = app.open(File(remainingFiles[i]));
// Dupe the other layers to the combined doc
openFiles.layers[0].duplicate(artboardStack, ElementPlacement.PLACEATBEGINNING);
openFiles.close(SaveOptions.DONOTSAVECHANGES);
// Call the artboard function
artBoardFromLayers();
}
app.beep();
alert('Stacking files to artboards completed!');
// Return the original ruler units
app.preferences.rulerUnits = origUnits;
// Functions
function artBoardFromLayers() {
app.runMenuItem(stringIDToTypeID("artboardFromLayersEvent"));
}
})();
} else {
alert('Please close all open files before running this script...');
}
31st July 2021 Update:
I made modifications from the basic unpublished 1.0 version of this script in the following topic thread:
Combining Mulitple Photoshop files into 1 Photoshop file with Artboards
Copy link to clipboard
Copied
What I do is offer custom sets of overlays for ECAMM and OBS users. Currently, I have 100 overlays in Inkscape but that program doesn't support artboards so I have to export each individually as PNG. I exported them black and white all of them as png, and I want to import them in photoshop as individual artboards, one next to each other and then create one smart object in each artboard but the SAME object (background) and then each of my photos will be used as a mask to mask out the transparent sections fro camera feed. So end result would be someone asks me to make him a pink overlay set, I go to a smart object, make it pink, export all artboards as png overlays. Speed up the process. I can make a background photo or anything. In smart object.
Copy link to clipboard
Copied
And also there is no way to convert all jpg files in one folder to png with photoshop? I tried action but it just gives me psb or jpg again.
By @Marinapomorac
You can create an action for use with the Batch command.
Or use Image Processor Pro or Picture Processor JavaScripts.
Copy link to clipboard
Copied
This script will require line 15 to be changed to include other formats, as it only opens PSD files...
i.e., from:
(psd)
to:
(jpg|tif|psd|psb|tga|png)
#target photoshop
// Batch Save As sRGB PNG.jsx
displayDialogs = DialogModes.NO
// raw.githubusercontent.com/jonahvsweb/Photoshop-Automated-Resize-to-Web.jsx/master/Automated%20Resize%20To%20Web.jsx
if (BridgeTalk.appName == "photoshop") {
app.bringToFront;
var inputFolder = Folder.selectDialog("Select the source folder that contains the PSD files for save as PNG:");
if (inputFolder != null) {
var fileList = inputFolder.getFiles(/\.(psd)$/i);
var outputFolder = inputFolder;
for (var i = 0; i < fileList.length; i++) {
if (fileList[i] instanceof File) {
var document = open(fileList[i]);
var documentName = fileList[i].name.replace(/\.[^\.]+$/, ''); // Regex remove filename extension
while (app.documents.length) {
var newFile = new File(decodeURI(outputFolder) + "/" + documentName + ".png");
// document.flatten (); // Disable flatten image step
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ConvertTosRGBProfile() {
app.activeDocument.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, false);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var pngOptions = new PNGSaveOptions();
pngOptions.compression = 0
pngOptions.interlaced = false;
app.activeDocument.saveAs(newFile, pngOptions, true, Extension.LOWERCASE);
app.activeDocument.close();
}
}
if (i == fileList.length - 1) {
alert("All PSD files have been saved as PNG files!");
}
}
}
}
Here is an Export/Save for Web version:
#target photoshop
// Batch Export SfW sRGB PNG.jsx
displayDialogs = DialogModes.NO
// raw.githubusercontent.com/jonahvsweb/Photoshop-Automated-Resize-to-Web.jsx/master/Automated%20Resize%20To%20Web.jsx
if (BridgeTalk.appName == "photoshop") {
app.bringToFront;
var inputFolder = Folder.selectDialog("Select the source folder that contains the PSD files for PNG export:");
if (inputFolder != null) {
var fileList = inputFolder.getFiles(/\.(psd)$/i);
var outputFolder = inputFolder ;
for (var i = 0; i < fileList.length; i++) {
if (fileList[i] instanceof File) {
var document = open (fileList [i]);
var documentName = fileList [i].name.replace(/\.[^\.]+$/, ''); // Regex remove filename extension
while (app.documents.length) {
var newFile = new File(decodeURI(outputFolder) + "/" + documentName + ".png");
// document.flatten (); // Disable flatten image step
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ConvertTosRGBProfile() {
app.activeDocument.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, false);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
exportOptions = new ExportOptionsSaveForWeb();
exportOptions.format = SaveDocumentType.PNG;
exportOptions.PNG8 = false; // false = PNG-24
exportOptions.transparency = true; // true = transparent
exportOptions.interlaced = false; // true = interlacing on
exportOptions.includeProfile = true; // false = don't embedd ICC profile
document.exportDocument(newFile, ExportType.SAVEFORWEB, exportOptions);
document.close(SaveOptions.DONOTSAVECHANGES);
}
}
if (i == fileList.length - 1) {
alert("All PSD files have been saved as PNG files!");
}
}
}
}