Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all 27456 articles
Browse latest View live

Re: Cannot read "rawData" of an XMP object

$
0
0

Hehe, not just this seems like a bug in ToolVM DOM We have to hack our way through. I often feel myself in an abandoned sanitarium.

 

By the way: the generator's backdoor/brain surgery approach is seems like much more useable in many cases than pure .jsx.


Re: Cannot read "rawData" of an XMP object

$
0
0

Well, not sure about what Tool DOM is, but if you mean this only happens in ELTK, I get the same error (well, I assume as I only get "ExtendScript error") inside my HTML panel.

 

What is that generator/backdoor you mention?

Re: Cannot read "rawData" of an XMP object

$
0
0

I call the PS Extendscript interpreter "ToolVM" and the HTML panels's v8 javascript engine "PanelVM". As I remember I saw this naming somewhere.

 

The backdoor is generator-core which can run from standalone nodejs or from node enabled panel. It can send .jsx snipplets via socket to PS and get back values from it with the help of Kevlar interface. It can retrieve the full document structure around 150 ms and has methods to store/retrieve custom, json data in the .psd.

 

Check out the

Generator.prototype.getLayerSettingsForPlugin = function (documentId, layerId, pluginId)
Generator.prototype.setLayerSettingsForPlugin = function (settings, layerId, pluginId)

methods.

Re: Cannot read "rawData" of an XMP object

$
0
0

Ah, that's very interesting, thank you! And that's what I'm actually doing, storing some custom JSON on the xmpMetadata object (I know it's supposed to be XML, but Photoshop doesn't seem to care, and it's easier for me to create, plus only my external tools are going to interpret this data from the PSD itself)

 

I'll take a look, thanks again!

 

P.D. This whole ecosystem seems in a broken/undocumented/abandoned state, I really concur with your sanitarium statement of before...

Re: Multiple Save Loops

$
0
0

You need to make your for loop recursive. So you put in an if statement to check if the any of the groups layers are layersets. If so, you call the same function.

 

var doc = activeDocument;
processLayers (doc)
function processLayers(gp){    for(var i=0;i<gp.layers.length;i++){        if(gp.layers[i].typename=='LayerSet'){            processLayers (gp.layers[i])            }//end if        else{            //put your code here to process regular layers            }//end else        }//end for loop    }//end function

Re: Save as png containing visible layer names Script

$
0
0

Hi man. Feel free to update savePNG(saveFile) function with this one. This will save PNG as if Compression: Smallest/Slow and Interlace: None are enabled

function savePNG(saveFile) {     var pngSaveOptions = new PNGSaveOptions();    pngSaveOptions.compression = 9;    pngSaveOptions.interlaced = false;    activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE); 
};

Re: photoshop script

Re: convert after effects photoshop

$
0
0

You are a great just what I wanted.


Re: Need Script Help for Batch Photo Editing

$
0
0

Thank you JJ for the reply. The image sizes are what our website design company are requesting. I agree the sizes are oversized, but they are being ran through a compression software before being uploaded; plus the images are being used at full size for the magnify glass effect when viewing the product.

To create folder and move a specific number of files

$
0
0

Hello Everyone,

 

The below screen grab is my existing folder.

 

existingfolder.jpg

 

Step 1: I would like to create a folder named with the file naming given above (chapter_001). The new folder looks like, chapter_001_01.

 

Step 2: I would like to move above files (3 files) to newly created folder.

 

Step 3: Again, create a folder named with the file naming given above (chapter_004). The new folder looks like, chapter_004_01.

 

Step 4: Again, move above files (3 files) to newly created folder.

 

As I am a beginner for this Javascript, I am unable to think that is possible to make a script to run this process.

 

It would be great if you could help me know whether this is possible for JS.

 

Thank you!

Re: Get timecode data using AM code

Starting scripts from the command line not working with Win10

$
0
0

Hey there - with Win 10 the following command will no longer work:

 

"C:\Program Files\Adobe\Adobe Photoshop CC 2015\Photoshop.exe" c:/trees/s2/game/temp/shg_sub_import_body_temp.jsx

 

It will open photoshop.  However, the script will fail to start and run.   I can run the script manually in photoshop without error.   This seems to be a permissions issue; however, toggling "run as administrator" doesn't make a difference.

 

Suggestions?   Is there a registry setting to fix this?  This is being run on a corporate network - so changing user account settings probably isn't an option. 

 

Also, there seems to be no official documentation of this functionality on the Adobe site.   I learned about this only searching via google.   Can this be corrected please?

Re: Starting scripts from the command line not working with Win10

$
0
0

It was the slash orientation.  However, my requested for documentation still stands - please.

Re: To create folder and move a specific number of files

$
0
0

Why would you want to do that in Photoshop?

Re: To create folder and move a specific number of files

$
0
0

Try this script. You need to change line one to the path of your current folder:

 

var curFolder = new Folder(Folder.desktop + '/Current Folder')//Change the path to wherever your current file is located
var mask = '*.xhtml';
var fList = curFolder.getFiles (mask);
var counter = 1;
var nextFolder;
var nextFolderName;
for(var i=0;i<fList.length;i++){    if(counter ==1){        nextFolderName = fList[i].name.split('.')[0];        nextFolder = new Folder(curFolder + '/' + nextFolderName + '_01');        if(!nextFolder.exists){nextFolder.create()};        }    counter++;    if(counter ==4){counter = 1};    fList[i].copy(nextFolder +'/' + fList[i].name);    fList[i].remove();    }

Re: EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.

$
0
0

Hello Lorin Lochridge,

 

I know it been a while, but I am stuck with almost the same problem.

I don't want this window to appear when saving a eps file via script.

 

epsSaveOptionsWindow.JPG

 

Did you find a solution or a workaround?

Any help would be highly appreciated!

 

Thanks in advance,

Christoph

Getting the path of linked (smart) object / PS Bug?

$
0
0

Hello All

 

i'm trying to read the path of the linked object/layer trough script. The path information seems to be available in the Layers properties panel (see screenshot 1).

When i try to use the command "reveal in finder" from within Photoshop, i do get an Error "Could not complete your request because of a program error."

So, i'm not able to use Scriptlistener to use the code for that.

 

Does anyone have a working AM code for this function available and knows why i do get this error on my side (on all psd documents i tried).

 

alert(app.activeDocument.activeLayer.filePath);

Designs_Front_psd___107___Classic_Camaro_Purple_White__RGB_8___.jpg

 

EDIT:

 

found this code that checks if there is a linked smart object and returns it's path.

Unfortunately i can't get it working like:

 

//Pseudocode:

If (activeLayer = linkedSmartobject)
{
var activeDesignPath = activeLayer.filePath;
} else {
// ignore ALL errors and continue (next layer will then be checked)
};

// Export/save as jpg to the root Folder of the linked smart object.
app.activeDocument.saveAs((new File(activeDesignPath + "/_Files Export/with GTO Background" +'/' + activeColor + ' ' + basename + ' ' + designDoc.activeLayer.name +'.jpg')),jpegOptions,true);

 

 

Original Script:

 

  if (app.documents.length)     {       var doc = app.activeDocument;       for (var ilayer = 0; ilayer < doc.artLayers.length; ilayer++)       {         var layer = doc.artLayers[ilayer];         if (layer.kind == LayerKind.SMARTOBJECT)         {            var ref = new ActionReference();         ref.putIdentifier(charIDToTypeID('Lyr '), layer.id );              var desc = executeActionGet(ref);         var smObj = desc.getObjectValue(stringIDToTypeID('smartObject'));         var localFilePath = smObj.getPath(stringIDToTypeID('link'));         }       }   }  

Re: Getting the path of linked (smart) object / PS Bug?

$
0
0

The code you found works for linked smart object layers it will through an error if the object is not a linked file. You can use a try catch to note the and ignore none linked smart object layers.

function processSmartObj(obj) {

  var localFilePath = "";

  var ref = new ActionReference();  

    ref.putIdentifier(charIDToTypeID('Lyr '), obj.id );  

    var desc = executeActionGet(ref);  

    var smObj = desc.getObjectValue(stringIDToTypeID('smartObject'));  

  try {

  var localFilePath = smObj.getPath(stringIDToTypeID('link')); 

  alert("Layer " + obj.name + ' linked file is"' +  localFilePath + '"');

  }

  catch(e) {}

  return localFilePath;

}

 

You could put some boilerplate around the process to structure the code an make it  more readable  for example process all layer in a document may look something like this.

/* ==========================================================
// 2017  John J. McAssey (JJMack)
// ======================================================= */
// This script is supplied as is. It is provided as freeware.
// The author accepts no liability for any problems arising from its use.
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher
// bring application forward for double-click events
app.bringToFront();
// ensure at least one document open
if (!documents.length) alert('There are no documents open.', 'No Document');
else {  // declare Global variables  //main(); // at least one document exists proceed    app.activeDocument.suspendHistory('Some Process Name','main()');
}
///////////////////////////////////////////////////////////////////////////////
//                            main function                                  //
///////////////////////////////////////////////////////////////////////////////
function main() {  // declare local variables  var orig_ruler_units = app.preferences.rulerUnits;  var orig_type_units = app.preferences.typeUnits;  var orig_display_dialogs = app.displayDialogs;  app.preferences.rulerUnits = Units.PIXELS;   // Set the ruler units to PIXELS  app.preferences.typeUnits = TypeUnits.POINTS;   // Set Type units to POINTS  app.displayDialogs = DialogModes.NO;     // Set Dialogs off  try { code(); }  // display error message if something goes wrong  catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }  app.displayDialogs = orig_display_dialogs;   // Reset display dialogs  app.preferences.typeUnits  = orig_type_units; // Reset ruler units to original settings  app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
}
///////////////////////////////////////////////////////////////////////////////
//                           main function end                               //
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// The real code is embedded into this function so that at any point it can return //
// to the main line function to let it restore users edit environment and end      //
/////////////////////////////////////////////////////////////////////////////////////
function code() {  processArtLayers(activeDocument) 
}
function processArtLayers(obj) {     for( var i = obj.artLayers.length-1; 0 <= i; i--) {processLayers(obj.artLayers[i]);}     for( var i = obj.layerSets.length-1; 0 <= i; i--) {processArtLayers(obj.layerSets[i]); } // Process Layer Set Layers 
}
function processLayers(layer) {  switch (layer.kind){  case LayerKind.SMARTOBJECT : processSmartObj(layer); break;  default : break; // none process layer types catch all  }
}
//////////////////////////////////////////////////////////////////////////////////
// Layer Type Functions //
//////////////////////////////////////////////////////////////////////////////////
function processSmartObj(obj) {  var localFilePath = "";  var ref = new ActionReference();       ref.putIdentifier(charIDToTypeID('Lyr '), obj.id );       var desc = executeActionGet(ref);       var smObj = desc.getObjectValue(stringIDToTypeID('smartObject'));     try {  var localFilePath = smObj.getPath(stringIDToTypeID('link'));    alert("Layer " + obj.name + ' linked file is"' +  localFilePath + '"');  }  catch(e) {}  return localFilePath;
}

Photoshop action to break apart a very large image into small square

$
0
0

Hi, I'm trying to record a Photoshop action to break apart a very large image into small square images and name them according to their grid number/letter. I did the first two rows for an example. Can you help me to develop an easier or better way to do this?

 

I will be using this to break apart various sizes of images into tiles to create large tile wall murals. We print the individual files onto ceramic tile so we need to name the files according to the grid so the installers will know which tile goes where on the wall. These tiles are 12in x 12in square. The large grid file is 26ft wide by 26ft tall. I will open the mural file and place it into this Photoshop file and size it to the size of the mural on the grid. When we run the script there will be a lot of blank tiles we won't need and will just delete.

 

Please see images which i have created via my record action and here is my action file for review please.

Capture.png

Thanks in advance 1a.jpg

Re: EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.

$
0
0

My memory is fairly vague on the details, but this is what my final script ended up to be:

(hope that helps)

 

try {

  var data = GetDataFromDocument( activeDocument );

  if ('eps' == data.extension.toLowerCase()) {

  //convert to cmyk

  converToCMYK ( rasterize = true ) ; 

  toSquare();

  epsSave();

  }

  else{

  //run code to square up images

  toSquare();

  saveQuit();

  }

}

catch( e ) {

  alert(e);

}

 

 

 

 

 

 

//FUNCTIONS

///////////////////////////////////////////////

///////////////////////////////////////////////

 

 

function toSquare(){

  var savedRuler= app.preferences.rulerUnits;

  app.preferences.rulerUnits = Units.PIXELS;

  var w = app.activeDocument.width;

  var h = app.activeDocument.height;

  if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);

  if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);

  //if w==h already square

  app.preferences.rulerUnits = savedRuler;

}

 

 

///////////////////////////////////////////////

 

 

function GetDataFromDocument( inDocument ) {

  var data = new Object();

  var fullPathStr = inDocument.fullName.toString();

  var lastDot = fullPathStr.lastIndexOf( "." );

  var fileNameNoPath = fullPathStr.substr( 0, lastDot );

  data.extension = fullPathStr.substr( lastDot + 1, fullPathStr.length );

  var lastSlash = fullPathStr.lastIndexOf( "/" );

  data.fileName = fileNameNoPath.substr( lastSlash + 1, fileNameNoPath.length );

  data.folder = fileNameNoPath.substr( 0, lastSlash );

  data.fileType = inDocument.fullName.type;

  return data;

}

 

 

///////////////////////////////////////////////

 

 

function converToCMYK( rasterize ) 

    var idCnvM = charIDToTypeID( "CnvM" ); 

    var desc39 = new ActionDescriptor(); 

    var idT = charIDToTypeID( "T   " ); 

    var idCMYM = charIDToTypeID( "CMYM" ); 

    desc39.putClass( idT, idCMYM ); 

    var idMrge = charIDToTypeID( "Mrge" ); 

    desc39.putBoolean( idMrge, false ); 

    var idRstr = charIDToTypeID( "Rstr" ); 

    desc39.putBoolean( idRstr, rasterize ); 

    executeAction( idCnvM, desc39, DialogModes.NO ); 

 

 

 

//////////////////////////////////////////////

 

 

function saveQuit(){

  var quitOut  = app.doAction("saveQuit", "Commands.atn");

  return quitOut;

}

 

 

//////////////////////////////////////////////

 

 

function epsSave() {

  var doc = app.activeDocument;

  var docName = doc.name;

  docName = docName.match(/(.*)(\.[^\.]+)/) ? docName = docName.match(/(.*)(\.[^\.]+)/):docName = [docName, docName];

  var suffix = '_300';

  var saveName = new File(decodeURI(doc.path)+'/'+docName[1]+suffix+'.eps');

  saveFile( app.activeDocument, saveName );

}

 

 

function saveFile( doc, saveFile ) { 

     var saveOptions = new EPSSaveOptions( ); 

     saveOptions.embedColorProfile = true;

     saveOptions.BINARY;

     saveOptions.halftoneScreen = false;

     saveOptions.interpolation = false;

     saveOptions.psColorManagement = false;

     saveOptions.transferFunction = false;

     saveOptions.vectorData = false;

     doc.saveAs( saveFile, saveOptions, true ); 

}

Viewing all 27456 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>