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

Photoshop CC 2018 - extended script - View mode issue

$
0
0

Dear Photoshop forum,

 

I’m noticing an issue with Photoshop CC 2018 and the extended script “.jsx” file I developed for Photoshop CC 2017.

 

My script works perfectly in Photoshop CC 2017 and both it's view modes “Standard screen mode” and “Full screen mode with menu bar”. In Photoshop CC 2017 I can launch the script and it returns a dialog that can be changed and its changes return a dialog with the corresponding changes.

 

In Photoshop CC 2018 my extended scripts works perfectly fine while in  the “Standard screen mode”. But while I’m in the “Full screen mode with menu bar” the dialog goes blank. When I move the mouse over the dialog some of its interface items are brought back but the majority of it remains blank. If I change a menu item that is shown by the mouse it makes the appropriate modifications.

 

It appears that the dialog's interface is being overwritten by the “view modes” white background while in “Full screen mode with menu bar”.

 

Is there something I need to add to my script so that it works properly?

 

Thanks

Rob

 

Screen Shot 2017-10-22 at 8.58.45 AM.png


create selection with color sampler

$
0
0

Hello everybody

 

I would like to create a selection using the selected points of the color sampler

I tried ScriptingListenerJS but I could not

 

I know I could use the color range

but I would like to do it without opening this window.

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?

multiple fonts in a textItem using jsx

$
0
0

Hi,

 

 

I am saving currentLayer.textItem.contents to a text file. That part is working. But I would also like to save attributes about the textItem, specifically the fonts being used and style attributes in the textItem.

However, I am only able to find the first font using currentLayer.textItem.font . Can I somehow find a list of all fonts and attributes used in a specific textItem?

 

 

Thanks

Debounce w/o setTimeout()?

$
0
0

Hi,

I'm looking for a way to implement a Debounce function (see here), like this one:

 

// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {  var timeout;  return function() {  var context = this, args = arguments;  var later = function() {  timeout = null;  if (!immediate) func.apply(context, args);  };  var callNow = immediate && !timeout;  clearTimeout(timeout);  timeout = setTimeout(later, wait);  if (callNow) func.apply(context, args);  };
};

 

To be used in ScriptUI.

Problem is that we don't have setTimeout in ExtendScript land, and $.sleep is blocking / not cancelable.

There is a working implementation for InDesign, using app.idleTasks, which, again, we don't have in Photoshop so back to square one.

Suggestions?

 

Thank you!

 

Davide Barranca

scale layer to current canvas size photoshop

$
0
0

I've been googling, and reading, but I have not been able to find an action, or method to select a layer, and have it scale to the canvas size? This seems to be something that should be built in?

 

Anyone know of a script or action I can use?

 

Sometimes it needs to scale up or down.

 

And I don't need to keep the proportions. Just scale to fill.

 

Thanks for your help

 

Maxi

 

PS: I know in Russell Brown's Paper Texture extension, the loaded layers are scaled to fit the canvas.

Watermark Script

$
0
0

Hi! I am in Photoshop now and would like to make an script for placing watermarks so that they take up 10% of the width of the image and are placed so that they are 3% in from the left and 3% from the bottom on the canvas. How do I do this?

For animated gifs: gifsicle sets Photoshops SaveForWeb parameter "lossy" to 60 that cannot be changed.

$
0
0

To batch save animated gifs I am using the great script written by SuperMerlin . Here it is:

 

#target photoshop; 

try{ 

var Path= activeDocument.path; 

}catch(e){var Path = "~/desktop";} 

var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, ''); 

var layerName = app.activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|]/g, "_"); 

var saveFile= new File(Path + "/" + Name + "-" + layerName + ".gif"); 

var rex = new RegExp(Name + "-" + layerName + ".gif"); 

var files = decodeURI(saveFile.fsName).replace(rex,"*.gif"); 

var cmd = 'C:/gifsicle.exe --batch --loop=forever --careful '; 

cmd += '\"' + files+ '\"'; 

SaveForWeb(saveFile); 

app.system(cmd); 

function SaveForWeb(saveFile) { 

var sfwOptions = new ExportOptionsSaveForWeb(); 

   sfwOptions.format = SaveDocumentType.COMPUSERVEGIF; 

   sfwOptions.includeProfile = false; 

   sfwOptions.interlaced = 0; 

   sfwOptions.optimized = true; 

   sfwOptions.transparency = 1; 

   sfwOptions.ColorReductionType = ColorReductionType.SELECTIVE; 

   sfwOptions.dither = Dither.NONE;   

   sfwOptions.ditherAmount = 0; 

   sfwOptions.lossy = 8;  

   sfwOptions.webSnap = 0; 

   sfwOptions.colors = 256; 

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions); 

};

 

And everything was great until I reinstall my computer. It looks like all photoshop and system parameters are as they were before but all my animated Gifs start to apear in a very poor quality after gifsicle. Exactly as poor as if you set in Export Option - SaveForWeb - parameter "lossy" to 60 for your animted gif.

 

If you open SaveForWeb - lossy is always set to 60 by default after using gifsicle. Otherwise it sets by default to whatever value was previously used.

 

I cannot fight that. Nothing helps so far. Would be very grateful for any help!


Did CC 2014.2 break textItem.size?

$
0
0

Scripts that worked before the update are now broken, and text layers created via script are all 12px. See this simple script:

 

var docRef = activeDocument;
var TextLabel = docRef.artLayers.add();
TextLabel.kind = LayerKind.TEXT;
TextLabel.name = "Test";
TextLabel.textItem.contents = "This text should be 50pt";
TextLabel.textItem.size = new UnitValue("50 points"); // other variations, such as TextLabel.textItem.size = 50 also fail.
TextLabel.textItem.font = "Monaco";

 

Any help? Thanks.

Load different image after 3 seconds on a palette

$
0
0

Hello everyone, a good week for everyone! Is there any way to load a sequence of 4 images.png "one at a time" every 3 seconds in the same coordinate in a palette. Each image would have 3 seconds of display: image1.png: 3seconds later = upload image2.png .... 3 seconds after uploading image3.png / 3 seconds after uploading image4.png My idea here is to improvise a kind of window like: Wait! Processing ...

converting actions into script

$
0
0

Hello Guys,

 

Might be a quick answer for you or maybe not.

I have never scripted anything in my life (except a few macro files in excel) and I am green to this.

 

Simple question - I have a few "actions" in photoshop and I would like them to be converted into scripts as it might come handy for the future as I will be working with some scripters.

So how do I transform this ATN file into a script?

 

The reason behind it is that I am already having one action that has 2 scripts in it and in the future I want to add more, so I will need someone scripting to work on the script itself not actions.

 

Maybe it is also counter-productive so give me your opinion,

 

thanks.

 

Olaf

Closing a document within Javascript.

$
0
0

I'm new here and new to javascripting in photoshop (though not new to javascript).

I've been trying to figure out how to do the equivalent of either the "File>Close" or the "File>Close All" menu item. Preferably programmatically specifying changes not be saved as the script will have saved what it wanted saved before closing.

I can't find a sample of this nor could I find other references to it in the forum. I'd appreciate any help that can be provided for this.

Thanks,

Steve Ellis.

$.getenv('Path')

$
0
0

$.getenv('Path')

 

 

- when you launch Photoshop and and run a script with above code or target Photoshop from Extendscript the first path from all displayed will be to Photoshop

 

 

- when you launch Bridge and and run a script with above code or target Bridge from Extendscript the first path from all displayed will be to Bridge

 

 

but:

 

 

- when you launch Photoshop and then run Bridge from Photoshop manually (File / Browse in Bridge...) or by script were is command to launch Bridge

and you use $.getenv('Path') whatever from Extendscript with targeted Bridge or from the script the first path there will be displayed won't be to Bridge but Photoshop!

 

 

- when you launch Bridge and then run Photoshop from Bridge manually (File / Open with Photoshop) or by script were is command to launch Photoshop

and you use $.getenv('Path') whatever from Extendscript with targeted Photoshop or from the script the first path there will be displayed won't be to Photoshop but Bridge!

 

 

 

 

Well it makes problem! Because no matter you run Photoshop and Bridge or Bridge and Photoshop,

where the second program is ran from your system or from first program it always should gives path of the program you target or run script from.

 

 

 

 

Scenario:

 

 

Some script works in Photoshop/Bridge but then needs information from Bridge/Photoshop.

 

 

a) If both programs were launched separately from system (Windows / OS), and then $.getenv('Path') is used all is okey.

 

 

b) If only one program was launched from system and second from that program which was lunched first or from the script targeted one program but then calling another $.getenv('Path') end is completely useless!

 

 

 

 

 

 

Is it bug or some specific behaviour? Well some users can open second program from that first or a script will do it. How then chance behaviour of that second program. I mean ho to make it could use $.getenv('Path') like it was launched from system?

 

 

For now it seems like first program is kind of parent of that second, like system for programs ran in. I can close by script that second program and use File(<path>).execute() of course to open that second program. Then it will be opened by system.

 

 

But it is not a way. If I did that then I had to use a path, which I don't know, so I want to get by $.getenv('Path') which has to tell me path to application I want to open (no matter there is also app.path). It's about finding solution for the problem I'm describing.

 

 

 

 

 

 

So command line and Autohotkey is no an option too, as in their cases I also has to put the path, which I can't know when I don't know were exacactly and what program is installed by someone who uses my script with $.getenv('Path')

 

 

 

 

Any ideas what can be done in this situation? If there is not then some workaround? and like I asked before is it bug or specific behaviour?

Is there any way to get interpolation type in Photoshop animation using JSX script?

$
0
0

I want to get the interpolation type of an animation using JSX script.

Is it possible?

If yes, How do we do it?

Running multiples scripts as sequence

$
0
0

Hi,

 

I'm using 4 scripts to manage all my website dev, to exports images, slice, etc..  It's an amazing way to work with scripting, god I love it !

 

I wonder if I can link all my script together so I don't have to wait for each one to end then start the next one manually.

 

Is there a way to script this so once my first script is done, it start the next one... and so on... an on... ?

 

 

Thanks guy if you have an idea !


Image Processor Pro not available in Bridge CC 2018

$
0
0

After updating to Photoshop CC 2018 and Bridge CC 2018 the Image Processor Pro (IPP) does not display under the Bridge > Tools > Photoshop menu.

The IPP dependencies were copied from the Photoshop 2017 to Photoshop 2018. The IPP can be accessed from Photoshop CC 2018 > File > Automate > Image processor Pro.. but not from Bridge CC 2018.

 

Currently, Photoshop CC 2017 and Bridge CC 2917 are installed locally and the IPP does display under the Bridge > Tools > Photoshop > Image Processor Pro...

Which IPP version have Mac users been able to successfully install in Bridge CC 2018 in OSX High Sierra?

 

Environment:

OSX High Sierra

MacBook Pro 2015

Help With Ps Script: Copy Group to a New PSD

$
0
0

Hi,

 

I'm trying to create a script that does the following:

 

  1. Checks for any open PSDs; if so, creates a new document named "Clipped Group."
  2. Iterates through all open PSDs.
  3. Checks for a group located at the top of the layer stack in current document called "Group 1." (should skip "Clipped Group" PSD)
  4. Copies "Group 1" (and any contents or masks attached to the group folder) and pastes it into the "Clipped Group" PSD.

 

I have gotten this far. The script breaks down starting at Line 28. I get an error message saying that "docRef.layerSets[0].copy" is not a function. I've been trying to piece together how to accomplish the above steps by reading the Adobe Photoshop Scripting guide, and checking forums, but I think I lack an understanding of how to use copy() and paste() or if those are even the methods I need. I'm pretty new at this -- if there was a way to work with what I have written so far, that would be great. Any help would be greatly appreciated. Thanks!

 

//Set Photoshop to use pixel measurements
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS


var docRef = app.activeDocument;


function makePackageDoc(filename) {
    if (app.documents.length > 0) {        var docHeight = 2000;        var docWidth = 2000;        app.documents.add(docHeight, docWidth, 300, "Clipped Group", NewDocumentMode.RGB, DocumentFill.TRANSPARENT, 1.0, BitsPerChannelType.EIGHT, "test");    };
};


function moveComponentGroup() {
    for (var i = 0; i < app.documents.length; i++) {  //Script iterates through all open documents.        docRef = app.documents[i];        var n = app.documents.length;        if (n > 0) {            if (docRef.name == "Clipped Group") {                continue;            };            var x = docRef.layerSets.length;            if ((x > 0) && (docRef.layerSets[0].name == "Group 1" )) {                docRef.layerSets[0].copy();                app.documents["Clipped Group"].paste();                       };        };    };
};


makePackageDoc("Clipped Group");
moveComponentGroup();

batch odd dimension images to square

$
0
0

Hi

 

I have lots of images that are all different sizes and more coming.

 

I need to create an action that makes these images square in px dimensions, with the new side dim. the dim. of the longest side.

 

I need to add canvas (light gray) to the short side.

 

I understand actions but not scripting.

 

Thanks exceedingly.

Get histogram of current layer (not the whole's document) by javascript, CC 2017

$
0
0

After searching for a few hours I am trying to get help here.

I can see it manually in Histogram panel and selecting "Selected layer" (I translated this name from my polish Photoshop so english may differ), but could not find any code snippets even reading scripting guide or js ref - pdfs.

How to script photoshop using C# .net 3.5

Viewing all 12244 articles
Browse latest View live


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