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

Re: CS5 - Error 22:Window does not have a constructor

$
0
0

The only other time I see this happen is if you are running the script from ESTK and the target app is not PS.

 

-X


Re: Getting average rgb value of an image on photoshop with javascript?

$
0
0

how would i particularly do this with javascript? and what does interpolation mean hah

A long shot ... in the dark .... for a "quick select" tool enhancement

$
0
0

I should not bother anyone with this that is just my problem, but here I am.

As I am using CS6 and it seems that there is no way to highlight the selection while selecting it.

I have hard time to see the "marching ants" and being that I need to work on pencil sketches that are B&W and not line art or something , lots of gray tones and dots and lines it frustrates me a lot.

None of the visualizing feature of selections/masks are dynamic , they are done in multiple steps. .

I know the script that I would like to create and I have already downloaded the guide and the references and I will try on my own.

In the mean time I would like to show you guys from where way,way out in the boonies I am starting ... here is the Idea:

 

10    trigger is = quick select selected '...........script should start when the tool is selected or used

20    my script = start

30    if quick select released      '.........................when the tool is not used (mouse up)

40        starting layer selected = false'....................... deselect selected layer

50        mock layer selected = true     '..........................select preset layer

         

70                     mock layer selection fill = opacity 50% – color blue '.................fill the selection in the preset-selected layer

 

90      end if

100    starting layer selected=true '....................... select original layer

 

 

I know that this will not highlight the selection as I select it ( or maybe it could if set on a timer function or detecting the mouse_move),

Anyway any help or ..... advice to desist will be both  appreciate.

 

If you know how to execute even one line of my ridiculous pseudo code please don't hesitate .... Thank you.Untitled-2.jpg

Re: A long shot ... in the dark .... for a "quick select" tool enhancement

$
0
0

To me it seems like you are describing  quick mask edit mode where you change Adobe default red overlay color and opacity to a blue color.

Capture.jpg

Re: Help with UI: Script execution order when selecting Radio and Checkbox options

$
0
0

You would put in after line 53. Line 52 checks to see if the okay button pressed and runs code accordingly.

Re: Getting average rgb value of an image on photoshop with javascript?

$
0
0

Using scriptListener, you could create a merged stamp visible layer ctrl-alt-shift-e for win. Then apply the average filter. You can then use the colorsampler to get what the average rgb value is and adjust the text layer accordingly. You can then delete the merged layer.

Re: Help with UI: Script execution order when selecting Radio and Checkbox options

$
0
0

Screenshot_1.jpg

Chuck Uebele, thanks to his tip, now yes, it worked perfectly. Once again thank you very much for your attention and this huge help.

Re: Export layers and Save as

$
0
0

c.pfaffenbichler  Sorry it's been a bit since I've had the opportunity to tackle this... I applied the settings you provided for saving as tifs, but I keep getting an error... It's stopping on the following line Marked with ****** below, any idea of why? I'm assuming this will work no matter if the document has 1 layer or multiple...???

 

 

// save tif of layers;

 

 

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

****** This one *************  var docName = myDocument.name;

****** This one ************* var basename = docName.match(/(.*)\.[^\.]+$/)[1];

var docPath = myDocument.path;

 

 

// tif options;

var tifOpts = new TiffSaveOptions();

tifOpts.embedColorProfile = true;

tifOpts.imageCompression = TIFFEncoding.TIFFLZW;

tifOpts.alphaChannels = false;

tifOpts.byteOrder = ByteOrder.IBM;

tifOpts.layers = false;

 

 

// get layers;

var theLayers = collectLayers(app.activeDocument, []);

 

 

// create the combinations;

for (var m = 0; m < theLayers.length; m++) {

          theLayers[m].visible = true;

          myDocument.saveAs((new File(docName + "_" + theLayers[m].name.replace("/","_") + ".tif")), tifOpts, true);

          theLayers[m].visible = false;

          };

};

 

 

////// function collect all layers //////

function collectLayers (theParent, allLayers) {

          if (!allLayers) {var allLayers = new Array}

          else {};

          for (var m = theParent.layers.length - 1; m >= 0;m--) {

                    var theLayer = theParent.layers[m];

// apply the function to layersets;

                    if (theLayer.typename == "ArtLayer") {

                              allLayers.push(theLayer);

                              theLayer.visible = false

                              }

                    else {

                              theLayer.visible = true

                              allLayers = (collectLayers(theLayer, allLayers))

                              }

                    };

          return allLayers

          };


Re: Export layers and Save as

$
0
0

What is the document’s name?

Has the document been saved at some point?

What exact error occurs?

Re: Export layers and Save as

$
0
0

What my overall plan is will be adding this to the bottom of another script that will watch a hot folder and open a .pdf (Single or Multi Page) then jump to this script and save each layer as a flattened .tif... When I'm running the script by itself from the script editor it stops and those lines turn orange.  I'll attach both scripts below so you can see what the ultimate plan is...

 

// opens all pages of pdfs cropped to trimbox with set settings; 

// 2011, use it at your own risk; 

#target photoshop 

var pdfOpenOpts = new PDFOpenOptions; 

pdfOpenOpts.antiAlias = true; 

pdfOpenOpts.bitsPerChannel = BitsPerChannelType.EIGHT; 

pdfOpenOpts.cropPage = CropToType.MEDIABOX; 

pdfOpenOpts.mode = OpenDocumentMode.CMYK; 

pdfOpenOpts.resolution = 300; 

pdfOpenOpts.suppressWarnings = true; 

pdfOpenOpts.usePageNumber  = true; 

// dialog for pdf-selection; 

var theFiles = app.openDialog(); 

if (theFiles) { 

// change pref; 

     var originalRulerUnits = app.preferences.rulerUnits; 

// change pref; 

     var originalRulerUnits = app.preferences.rulerUnits; 

     app.preferences.rulerUnits = Units.INCHES; 

     for (var m = 0; m < theFiles.length; m++) { 

          var theFile = theFiles[m]; 

          if (theFile.name.slice(-4) == ".pdf") { 

               var thePdf = openMultipagePDF(theFile); 

                    }; 

               } 

          } 

// reset pref; 

     app.preferences.rulerUnits = originalRulerUnits; 

 

function openMultipagePDF(myPDFFile) { 

// suppress dialogs; 

     var theDialogSettings = app.displayDialogs; 

     app.displayDialogs = DialogModes.NO; 

     var myCounter = 1; 

     var myBreak = false; 

     while(myBreak == false){ 

          pdfOpenOpts.page = myCounter; 

          try { 

               var thePdf = app.open(myPDFFile, pdfOpenOpts); 

               thePdf.flatten(); 

               thePdf.layers[0].isBackgroundLayer = false; 

               //thePdf.layers[0].name = myPDFFile.name+"_"+myCounter; 

               if (myCounter == 1) { 

                    var theFile = thePdf 

                    } 

               else { 

                    thePdf.layers[0].duplicate(theFile, ElementPlacement.PLACEATBEGINNING); 

                    thePdf.close(SaveOptions.DONOTSAVECHANGES) 

                    } 

               } 

          catch (e) {myBreak = true}; 

          myCounter = myCounter + 1; 

          }; 

// reset dialogmodes; 

     app.displayDialogs = DialogModes.ERROR; 

     return app.activeDocument 

     }; 

*******Your script starts below **************

// save tif of layers;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var docName = myDocument.name;

var basename = docName.match(/(.*)\.[^\.]+$/)[1];

var docPath = myDocument.path;

 

 

// tif options;

var tifOpts = new TiffSaveOptions();

tifOpts.embedColorProfile = true;

tifOpts.imageCompression = TIFFEncoding.TIFFLZW;

tifOpts.alphaChannels = false;

tifOpts.byteOrder = ByteOrder.IBM;

tifOpts.layers = false;

 

 

// get layers;

var theLayers = collectLayers(app.activeDocument, []);

 

 

// create the combinations;

for (var m = 0; m < theLayers.length; m++) {

          theLayers[m].visible = true;

          myDocument.saveAs((new File(docPath+"/"+ docName + "_" + theLayers[m].name.replace("/","_") + ".tif")), tifOpts, true);

          theLayers[m].visible = false;

          };

};

////// function collect all layers //////

function collectLayers (theParent, allLayers) {

          if (!allLayers) {var allLayers = new Array}

          else {};

          for (var m = theParent.layers.length - 1; m >= 0;m--) {

                    var theLayer = theParent.layers[m];

// apply the function to layersets;

                    if (theLayer.typename == "ArtLayer") {

                              allLayers.push(theLayer);

                              theLayer.visible = false

                              }

                    else {

                              theLayer.visible = true

                              allLayers = (collectLayers(theLayer, allLayers))

                              }

                    };

          return allLayers

          };

Re: Export layers and Save as

$
0
0

There is your problem, I guess – a file that has been created by converting a pdf is new, it has no suffix yet.

What happens when you remove the line

var basename = docName.match(/(.*)\.[^\.]+$/)[1];

?

Re: A long shot ... in the dark .... for a "quick select" tool enhancement

$
0
0

Yes and no, the quick mask mode does not have the "smartness" that the magnetic or quick select tool have.

It is the closest thing to what I need, but (as far as I know ) it uses the brush to create the selection.

Could the quick mask mode be somewhat integrated with the magnetic or quick select tool ?

Thank you

 

Addendum:

Is it possible to change with a script the default b&w dots of the marching ants to a neon color an thicker then 1px ?

(Believe it or not the right side has a "visible" marching ants selection.)

Untitled-8.jpg

Re: Export layers and Save as

$
0
0

Well interesting... I had never combined the two elements yet to run as one.. I was just trying to get the tiff save portion working... However, I removed the line you suggested and went ahead and ran the combined script and it seemed to work... Thanks for your help...

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

$
0
0

Schubser,

 

Is that possible to assign the location and number of files manually?

 

I want to assign the location and number of files manually because the numbers is not constant.

 

Thanks

Bug: Logical && and || operator precedence is broken

$
0
0

Not sure if this is the right place to report this.

 

In Boolean algebra, the logical AND operator has higher order-of-operations precedence than logical OR. Therefore, the following two expressions should be equivalent:

 

(true && true) || (true && false) // Result: true
true && true || true && false // Result: false in JSX (should be true)

 

In JSX, their results vary as indicated. The second expression is equivalent to this:

 

((true && true) || true) && false

 

This does not follow logical order of operations. I confirmed that the two expressions both evaluate to true in other JavaScript engines.

 

Workaround: Always use parens, but now I can't run my code through a minifier or obfuscator because it removes the extra parens to make the code smaller.


Breaking Selection into different layers

$
0
0

If i had a segmented selection, is there a way to identify that the selection is not one concave shape?
i could then identify them and put each of them into different layers.

 

 

All these different shapes are  in one layer, and I've selected the active pixels in the layer.

Untitled-2.jpg

Is there a way to identify that they are separate them objects into separate them into different layers?

Untitled-3.jpg

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

Re: Export layers and Save as

$
0
0

OK... I must have gotten lucky the first time, because now it's stopping at the

var docPath = myDocument.path;

 

Line... Any ideas?

Re: Open Multi Page pdf Script - Sized to Media Box

$
0
0

OK.. quick question I'm working on this trying to finish my process... I can get your script to work great opening the multi page .pdf, but what I'm wanting to do is change it from opening a dialog box to choose the file to grab all the files in a particular folder... I've got a script I use in illustrator to do this, but it's obviously not transferring well to Photoshop... Any suggestions...???

 

Another difference in this case... I'm not trying to paste into a currently open document, so I know the verbiage will need to change but not sure how to make it happen

 

Thanks

 

#target illustrator  ////Obviously this will change to Photoshop/////

 

var Zundtmpfile = File('~/Desktop/Illustrator Hot Folder/#/Templates/ZundTmp/Zund Setup.ait'); ///won't need this part for Photoshop since it's opening a new file       based on the .pdf command///

app.open(Zundtmpfile); /// Not Needed

 

 

//Place New Image 

var fo = Folder ( '~/Desktop/Test/IN' ); 

var files = fo.getFiles ( /* you may want to use a filter function here. See doc */ ); 

var file, newimage; 

   

while ( file = files.pop() ) { 

var aDoc = app.activeDocument; 

  newimage = aDoc.placedItems.add();  

  newimage.file = file;  

  newimage.position = [200,-300]; 

Re: A long shot ... in the dark .... for a "quick select" tool enhancement

$
0
0

Adobe Marching Ants only outline Pixels the are mor than 50% selected.  A script can not chant that or change how the marching ants are displayed.  A script could add a work layer on top  and fill the selection with a color and stroke the layer with a neon color so many pixels wide so you can see what the selection looks like better. But if you alter the selection the work layer would need to be deleted and re-created.

Viewing all 27456 articles
Browse latest View live


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