Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all 12244 articles
Browse latest View live

Please Help "Copy to Clipboard" not recorded in Actions

$
0
0

Hi There

 

When I try to Copy values on Canvas Size (e.g. value on Height Copied to Width or reverso so as Height = Width) then I want to repeat this "Copy" task to all remaining Opened Files using Actions, these "Copy" task is not recorded but it just Copies The first Value I Copied in the first action

 

Example:

 

Picture 1 has the Canvas Size
Height : 27 Inches
Width : 18 Inches

 

 

Picture 2 has the Canvas Size
Height : 24 Inches
Width : 10 Inches

 

First, I use Actions and start to record
Then, I Copy value on Height and paste it to Width on Picture 1
Then, I click Stop

 

The problem arise when I repeat this "Copy" task on Picture 2, the Height won't be the same as Width and the Width is the value I Copy for the first time i.e. 27 Inches

 

So the result is

 

Picture 2 has the Canvas Size
Height : 24 Inches
Width : 27 inches  (not 24 Inches)

 

Hope you can help me with this

 

Thanks before


Weird layer-renaming issue.

$
0
0

On Win7, PS 19.0 I am encountering a strange issue with renaming layers.

 

It boils down to these steps:

  1. start a fresh PS
  2. Rename a layer manually works just fine.
  3. Run a layer-making script
  4. Now, renaming layers manually is nearly impossible: you double-click the desired layer to enable editable layer name text, but only have 1 second to type in the entire input before it automatically sets.

 

What's worse, after this the layer issue persists even in new documents, all the way until app restart.

 

This is my layer-making script:

 

#target photoshop

function test(){

  var doc = app.activeDocument;

  var arr = [

    "Name 1",

    "Name 2"

  ];

  var newLayer;

  for(var i = 0; i < arr.length;  i++){

    newLayer = doc.artLayers.add();

    newLayer.name = arr[i];

  };

};

test();

 

Has anyone come across this?

Actions/Scripts: Move layer to absolute position instead of translate

$
0
0

Hey all,

 

Im trying to write a script which takes a layer and moves it to a x/y coordinate on the canvas rather than translates the object a certain amount of pixels. Ive created an action so far and converted it to a script file to try and tweak it but am having trouble understanding the API. I was hoping someone here might be able to help.

 

Here is the step that I need to adjust from a translate to an absolute position:

 

 

  // Transform

 

  functionstep9(enabled, withDialog) {

   if (enabled != undefined&& !enabled)

   return;

   vardialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

   vardesc1 = newActionDescriptor();

   varref1 = newActionReference();

   ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));

   desc1.putReference(cTID('null'), ref1);

   desc1.putEnumerated(cTID('FTcs'), cTID('QCSt'), sTID("QCSAverage"));


   vardesc2 = newActionDescriptor();

   desc2.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 0);

   desc2.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800);

   desc1.putObject(cTID('Ofst'), cTID('Ofst'), desc2);


   vardesc3 = newActionDescriptor();

   desc3.putEnumerated(sTID("warpStyle"), sTID("warpStyle"), sTID("warpNone"));

   desc3.putDouble(sTID("warpValue"), 0);

   desc3.putDouble(sTID("warpPerspective"), 0);

   desc3.putDouble(sTID("warpPerspectiveOther"), 0);

   desc3.putEnumerated(sTID("warpRotate"), cTID('Ornt'), cTID('Hrzn'));

   desc3.putInteger(sTID("uOrder"), 4);

   desc3.putInteger(sTID("vOrder"), 4);

   desc1.putObject(cTID('warp'), cTID('warp'), desc3);

   desc1.putEnumerated(cTID('Intr'), cTID('Intp'), cTID('Bcbc'));

   executeAction(cTID('Trnf'), desc1, dialogMode);

  };

 

 

Thank you in advance for the help!

Scripting Lens Correction to process millions of photos

$
0
0

We have several million "Fish-Eye" images that we need to flatten out and the new "Lens Correction" feature of Photoshop CS5 appears to work pretty well.  I was able to use the predefined File -> Automate -> Lens Correction function to process a hanfull of images and it worked fine for a small batch.

 

I would like to know if there is a way with Photoshop CS5 to script/batch out a process so that I can use it to process the millions of individual files we need to have processed.

 

Also, I am not familiar with the Photoshop "Batch" or "Scripting" process, so assuming the above request is possible, some direction on how to proceed would be greatly appreciated.

 

Thank You.
Lee

photoshop scripting output

$
0
0

Is there a console or log for output from script events?  I tried making a function, which executes an alert correctly, but doesn't create a new document.  I can't find any way to see if this syntax is wrong or the command is just outdated. 

 

In the code below, for example, I see the alert message, but no new document.  I don't see anyway to see what's wrong with it and I pulled that line straight from the photoshop scripting guide. 

 

var createDocument = function() {

    alert("creating new doc!");

    app.documents.add(2,4);

};

How to record an action for healing brush/clone tool ?

$
0
0

Hi,

 

most of you who know photoshop so well, know it's a fact it's impossible to record an healing brush or a stamp tool to apply. Also is knowns the patch tool is the only way to make theses kinds of corrections and record them but the patch tool is not doing a great job as the healing brush, if you know your stuff.

 

This situation is never the less something many can experience, shooting products and having the same spots, dust and scratch to remove over 600 images is a major challenge.

 

I know when photoshop cannot record tools or specific task then scripting is the way to go.

Will scripting can open new possibilities to use healing brush corrections over an image to apply over many others doing the same corrections ?

 

Also I'll post this in the request for new versions or updates coming up in photoshop family page.

 

Mark

List folders only one heirarchy lower than selected top level?

$
0
0

Directory structure

Top level folder

     ->Subs

          ->subsubs

 

How would I indicate not to search all subfolders, but only folders one level under the top level? Thanks! Not my code.

 

 

#target photoshop; 
var folders =[]; 
var topLevel = Folder.selectDialog("Please select top level folder");     
folders = FindAllFolders(topLevel, folders); 
folders.unshift(topLevel); 
var List = []; 
for(var a in folders){List.push(decodeURI(folders[a].name));} 
alert(List.join("\n"));  
function FindAllFolders( srcFolderStr, destArray) {     var fileFolderArray = Folder( srcFolderStr ).getFiles();     for ( var i = 0; i < fileFolderArray.length; i++ ) {         var fileFoldObj = fileFolderArray[i];         if ( fileFoldObj instanceof File ) {                     } else {          destArray.push( Folder(fileFoldObj) );         FindAllFolders( fileFoldObj.toString(), destArray );         }     }     return destArray; 
}; 

Show/Hide Selection Edges

$
0
0

Hi

I'm new in Adobe scripting. I hope i can find some help here

 

I need a snippet can show/hide current layer selection ( not deselect ) which command trigger in "View> Show> Selection Edges" menu

 

I dont see it record in history or log . Is there any way to access it or trigger shortcut via javascript code ?

 

Thanks

Dzung


error on this line ...

$
0
0

Hello everyone
In this script ExtendScript indicates an error but I can not understand which one.
I am under CS6 on mac.
If anyone sees or is the problem ... thanks

JL

 

function SaveJPEG(saveFile, jpegQuality){  

var doc = activeDocument;  

if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) doc.bitsPerChannel = BitsPerChannelType.EIGHT;  

jpgSaveOptions = new JPEGSaveOptions();  

jpgSaveOptions.embedColorProfile = true;  

jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;  

jpgSaveOptions.matte = MatteType.NONE;  

jpgSaveOptions.quality = jpegQuality;   

      activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);  >>error on this line !?

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)

};

how do I get the name of the action that was started from within my javascript?

$
0
0

Hello,

 

I want to create an action called 'test1' and record it playing a script called 'generic.jsx'.

I want the script to know that it was started by 'test1' and thus, do XYZ.

I want to create another action called 'test2' and have it play the same script called 'generic.jsx'.

From within that same script, being a generic one, I want to to now know that it was started by action 'test2' and do ABC.

 

How can I have my javascript know the name of the action that launched it?

 

Thanks in advance!

 

---

Shai

Replace text in text layers

$
0
0

I found a function from c.pfaffenbichler here on the forum, which will search/replace text. The script works great if you have a flat document, but as soon as you create a group the script won't work anymore.

 

Here's the function:

function replaceText (searchText, replaceWith)
{    var actionDes1 = new ActionDescriptor();    var actionRef = new ActionReference();    actionRef.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID("replace") );    actionRef.putEnumerated( charIDToTypeID( "TxLr" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Al  " ) );    actionDes1.putReference( charIDToTypeID( "null" ), actionRef );    var actionDes2 = new ActionDescriptor();    actionDes2.putString( stringIDToTypeID( "find" ), searchText );    actionDes2.putString( stringIDToTypeID("replace"), replaceWith );    actionDes2.putBoolean( stringIDToTypeID( "checkAll" ), false );    actionDes2.putBoolean( charIDToTypeID( "Fwd " ), true );    actionDes2.putBoolean( stringIDToTypeID( "caseSensitive" ), false );    actionDes2.putBoolean( stringIDToTypeID( "wholeWord" ), false );    actionDes2.putBoolean( stringIDToTypeID( "ignoreAccents" ), true );    actionDes1.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "findReplace" ), actionDes2 );    executeAction( stringIDToTypeID("replace"), actionDes1, DialogModes.NO );
};
replaceText ("test", "replaceWithStuff")

 

Here's the error I get:

---------------------------
Error
---------------------------
Error 8800: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The object "in contents of all text layer" is not currently available.
Line: 21
->      executeAction( stringIDToTypeID("replace"), actionDes1, DialogModes.NO );
---------------------------
OK  
---------------------------

 

Does anyone know how to work around this problem? I've tried a try/catch, the only thing that does is to suppress the error, but it won't replace the text :/

Colouring buttons

$
0
0

Via a button I n a dialog box, I invoke the colorPicker.  I want to have the button background recoloured to match the selected colour (a la the foreground/background colours tool icon in PS).

 

Over on the InDesign Scipting forum there is a very old threat (C2009, IRRC) about colouring buttons (background and text).  Dirk Beker posted the following code:

 

function customDraw()

{ with( this ) {

graphics.drawOSControl();

graphics.rectPath(0,0,size[0],size[1]);

graphics.fillPath(fillBrush);

if( text ) graphics.drawString(text,textPen,(size[0]-graphics.measureString (text,graphics.font,size[0])[0])/2,3,graphics.font);

}}

 

var dlg = new Window('dialog', 'Test');

var pnl = dlg.add('panel', undefined, 'My Panel');

var btn = pnl.add('button', undefined, 'My Button', {name:'ok'});

var btn2 = pnl.add('iconbutton', undefined, undefined, {name:'orange', style: 'toolbutton'});

btn2.size = [200,20];

btn2.fillBrush = btn2.graphics.newBrush( btn2.graphics.BrushType.SOLID_COLOR, [1, 0.7, 0, 0.5] );

btn2.text = "Hello, Harbs";

btn2.textPen = btn2.graphics.newPen (btn2.graphics.PenType.SOLID_COLOR,[0,0.5,0,1], 1);

btn2.onDraw = customDraw;

dlg.show();

 

This seems to work in PS CC2019 (under Win10 and High Sierra) but sometimes the background colour isn't updated and sometimes there is a (variable) delay before the colour changes.  I can (almost) live with that.

 

What puzzles me is why ' customDraw() ' appears to be invoked on mouseover - every time.  There is no scriptListener running, and nothing set anywhere - that I can determine - which might explain this behaviour.

 

Any thoughts, please?

Check if the color sampler is present

$
0
0

I tried this solution but it does not work

Where am I doing wrong

 

var doc = activeDocument; 

try{ 

   if (activeDocument.colorSamplers.length > 0)

 

   {alert ("color sampler/s exist/s")};

   

     } 

 

catch(){ 

 

       {alert ("color sampler/no exist")};

    

     }

Abort the default Photoshop progress bar

$
0
0

Screenshot_2.jpg

Hello everyone! Is there any way to abort or hide this "standard progress bar" when exporting high-quality prints through scripts?

I added a custom progress bar to my script that took too long but I sometimes realize that the two palettes are shown at the same time? It would be possible?

 

That's the palette I'm using! If someone has another functional model I am very grateful

myPrs = new Window('palette', 'Batch Processing');     myPrs.orientation = 'column';     myPrs.alignment = 'right';     myPrs.ProcessHead  = myPrs.add('statictext',[40,0,260,25], "Batch Processing...");     myPrs.Process = myPrs.add("progressbar",[40,40,260,65]);     myPrs.Label = myPrs.add('statictext', [150,75,200,120], "0%");     myPrs.Process.value = 0;     var LENGTH = 4;     myPrs.show();     for(i=0;i<1;i++){         var PrCounter = 0;        ProgressBar(++PrCounter, i+1 , 1);         Function1();     }           function ProgressBar(v, x, y){         var value = (Number(v) / LENGTH) * 100;         myPrs.Label.text = Math.round(value) + " % ";         myPrs.ProcessHead.text = "Batch Processing... [" + x + "/"+ y + "]";         myPrs.Process.value = value;     }       function Function1(){      // my code     }

Batch Crop & Straighten

$
0
0

A while ago a good chap helped me out by creating a script that prompted the user for a folder, then ran the Crop and Straighten Photos command on all images contained in the folder and saved the newly created photos in a new folder.  The script is below.

 

The script saves cropped photos as PNGs, I'd like to save them as JPEG.  Could someone help me out by tweaking the script to save as JPEG?  I'd like them saved with the highest quality option.

 

#target Photoshop
app.bringToFront;
var inFolder = Folder.selectDialog("Please select folder to process");
if(inFolder != null){     var fileList = inFolder.getFiles(/\.(jpg|tif|png|)$/i);     var outfolder = new Folder(decodeURI(inFolder) + "/Edited");     if (outfolder.exists == false) outfolder.create();     for(var a = 0 ;a < fileList.length; a++){          if(fileList[a] instanceof File){               var doc= open(fileList[a]);               doc.flatten();               var docname = fileList[a].name.slice(0,-4);               CropStraighten();               doc.close(SaveOptions.DONOTSAVECHANGES);               var count = 1;               while(app.documents.length){                    var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".png");                    SavePNG(saveFile);                    activeDocument.close(SaveOptions.DONOTSAVECHANGES) ;                    count++;               }          }     }
};

function CropStraighten() {
     function cTID(s) { return app.charIDToTypeID(s); };     function sTID(s) { return app.stringIDToTypeID(s); };     executeAction( sTID('CropPhotosAuto0001'), undefined, DialogModes.NO );
};

function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();    pngSaveOptions.embedColorProfile = true;    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;    pngSaveOptions.matte = MatteType.NONE;    pngSaveOptions.quality = 1;     pngSaveOptions.PNG8 = false; //24 bit PNG    pngSaveOptions.transparency = true;     activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}

function zeroPad(n, s) {
     n = n.toString();     while (n.length < s) n = '0' + n;     return n;
};

Why do buttons in two panels have different corners

$
0
0

The following working code creates two 'identical' buttons in two separate panels in a single dialog box.

 

The buttons in the upper panel are shown with rounded corners, those in the lower panel are shown with square corners.

 

Can anyone please explain why; and also how the same (rounded or square) corners may be achieved for buttons in both panels.

 

    var box = new Window( 'dialog', "Test corners of buttons" );

 

    box.panel1 = box.add( 'panel', undefined, "" );

   

    box.panel1_cancelBtn = box.panel1.add( 'button', undefined, "Cancel" );

    box.panel1_createBtn = box.panel1.add( 'button', undefined, "Create" );

 

    box.panel2 = box.add( 'panel', undefined, "" );

   

    box.panel2_cancelBtn = box.panel2.add( 'button', undefined, "Cancel" );

    box.panel2_saveBtn = box.panel2.add( 'button', undefined, "Save" );

   

    box.panel1_cancelBtn.onClick = function() { box.close() };

    box.panel2_cancelBtn.onClick = function() { box.close() };

 

    box.show();

 

For information only, the code has been greatly simplified from a lengthy and complex function [that otherwise works to my satisfaction] that creates a dialog box with some initially inactive panels that are individually activated by clicking an 'OK' button in an active panel.  The other code in the function is not relevant, that shown above demonstrates the issue.

 

The behaviour is observed in ESTK / PS CC 2018 (19.0) under both Windows10 and High Sierra.

 

It's not a big issue, but the lack of visual consistency irritates me, as does my lack of understanding as to why there is a difference.

Using mouse wheel to zoom and pan

$
0
0
I was wondering if there would be a way to make a javascript that would load at Photoshop's startup that would allow the user to zoom in and out using the mouse wheel (instead of using it for scrolling), and to use that same mouse wheel as a third button (when you push on the mouse wheel) or any third button on a three button mouse to pan in your image. I'm a 3ds max user and I love the way the navigation work in that software so it'd be great to be able to do that for Photoshop and Illustrator and get rid of those useless key shortcuts that we need to use to zoom and pan.

For the pan fonction, I guess if there was a way to simply say "when the third mouse button is pressed, press the space button, until the mouse button is released" it could work. But then it would force the panning to stop when the mouse goes offscreen, unlike in 3ds max where you can pan for whatever distance you want, even if you have the loop throught the screen ten times.

For the zoom function, if scolling up could simply "push" the keyboard shortcuts to zoom in/ zoom out it could work, but I don't know if that's possible. And then we'd have to disable the scrolling up and down in the document.

Anyways, if anyone has any ideas about that let me know! I've been looking for that for such a long time!

Data Sets in Photoshop Error

$
0
0

how to i fix this? Could not parse the file contents as a data set. There were too many variable names in the first line of the text file.

How to active ruler / grid with script?

$
0
0

Hello,

 

i try to develop a plugin and the last issue i have to fix is to add a button witch can toggle the grid and the rulers.

i have tried it with the ScriptListerner but the Code Result always break.

 

have anybody a solution for that problem?

 

Target: PhotoShop CC 2018

Searching Arrays - indexOf

$
0
0

I was trying to search an array, and on the web it says to use something like this:

 

var tA = ['one','two'];

$.writeln(tA.indexOf ('one'))

 

However, when I try this, I get: tA.indexOf is not a function."  It works with a string variable but not an array.  Is this a bug, or an I doing something wrong?

Viewing all 12244 articles
Browse latest View live


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