Ghoul Fool
Engaged
Ghoul Fool
Engaged
Activity
‎Feb 25, 2023
02:40 AM
What size image did you use (width, height) ? And also I'm using an antique version of 19.1.6
... View more
‎Feb 25, 2023
01:29 AM
And pray tell, what purpose does that serve exactly?
... View more
‎Feb 24, 2023
11:22 AM
I've only just found out about Suspend History! - it need to be better documemented 🙂 // Suspend History, man
app.activeDocument.suspendHistory ("My history state", "my_function(param1, param2)"); Technical question: the firest parameter is a string, the history state name. But why is the second parameter a string also and not a function literal?
... View more
‎Feb 24, 2023
09:44 AM
Makes no difference if Layer Bounds or Entire Document are chosen.
... View more
‎Feb 24, 2023
09:07 AM
I'm not sure if this is intentional, but it can certainly be a feature: Is there anyway to stop Photoshop resizing the text layer icon? See exhibit 1, background and text layer And now when the image is rotated by 90 degrees (and changing the aspect ratio) it shrinks: Naturally, I've wasted a lot of my mind and time figuring this out. Is there any way to stop it happening?
... View more
‎Jan 30, 2023
01:27 AM
I suspect you're right I probably am running out of disk space on C:\ For what it's worth here's the script. It changes 16 bit images to 8 bit save and closes them or just closes them if they are not 16 bits per channel. // Switch off any dialog boxes
displayDialogs = DialogModes.NO; // OFF
var inFolder = Folder.selectDialog("Please select folder to process");
if (inFolder != null)
{
var fileList = inFolder.getFiles(/\.(png)$/i);
}
var num = fileList.length;
main(fileList);
// Switch any dialog boxes back on again
displayDialogs = DialogModes.ALL; // ALL ON AGAIN
function main(flist)
{
var bits = 8;
for (var i = 0; i < flist.length; i++)
{
// open file
open_it(flist[i]);
// call the source document
var srcDoc = app.activeDocument;
// if there's a document open
// changes it's bit depth
if (documents.length != 0)
{
if(srcDoc.bitsPerChannel == "BitsPerChannelType.SIXTEEN")
{
change_bits_per_channel(bits);
save_and_close_it();
}
else close_it();
} // end documents.length != 0
}
}
function change_bits_per_channel(x)
{
// =======================================================
var idCnvM = charIDToTypeID( "CnvM" );
var desc28 = new ActionDescriptor();
var idDpth = charIDToTypeID( "Dpth" );
desc28.putInteger( idDpth, x ); // bits per channel
var idMrge = charIDToTypeID( "Mrge" );
desc28.putBoolean( idMrge, false );
executeAction( idCnvM, desc28, DialogModes.NO );
}
// function CLOSE IT()
// --------------------------------------------------------
function close_it()
{
// close the image WITHOUT saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
// function SAVE AND CLOSE IT
// ----------------------------------------------------------------
function save_and_close_it()
{
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
// function OPEN IT (filename & path)
// --------------------------------------------------------
function open_it(afilepath)
{
// simple version
var theFile = new File(afilepath);
if (theFile.exists)
{
var id511 = charIDToTypeID( "Opn " );
var desc109 = new ActionDescriptor();
var id512 = charIDToTypeID( "null" );
desc109.putPath( id512, new File(afilepath) );
executeAction( id511, desc109, DialogModes.NO );
}
else // file doesn't exist
{
// alert("Cannot open\n" + afilepath);
}
}
... View more
‎Jan 29, 2023
03:50 AM
Does anyone know if there is a limit to the number of file you can process at any time? Obviously milage may vary 🙂 I had a simple script that worked. Tried it as a batch process on a folder of 13,918 images and it just fell over. So I re-wrote the script to process a folder 1000 images at a time. On the fifth or so iteration it fell over and photoshop crashed. Worked fine after re-starting Photoshop In the end I managed to process all the images but it was a bit hit and miss. So, is there a sort of maximum limit set in Photoshop image process wise?
... View more
‎Jan 20, 2023
03:56 AM
Remind me to look into windows that are duplicated. - ie New window for (Window > Arrange > new window for doc XYZ) As those aren't covered int he same way.
... View more
‎Jan 13, 2023
01:31 AM
That's a clever script. Possibly overkill for my needs - My script is just grabbing or putting guides from one document to another - for a one shot/ one button script it just needs to work out is there a document with the same dimensions already open? And is it missing guides?
... View more
‎Jan 12, 2023
08:44 AM
1 Upvote
var theDocs = app.documents;
for (var i = 0; i < theDocs.length; i++)
{
msg += theDocs[i].name + "\n";
}
alert(msg) That gives the cocuments that wer opened in order, which not quite what I was after. I'm sure I'll work something out.
... View more
‎Jan 11, 2023
11:41 AM
Does Photoshop keep an array of it's activeDocuments? Not a list of the documents history, which is held in documents. But Photoshop files that are currently open. So app.activeDocument[1] would be the document you used last and app.activeDocument[0] is the current one. for (var i = 0; i < activeDocuments.length; i++)
{
// Something
} Obviously the above doesn't work. - But you get the idea. Hopefully.
... View more
‎Jan 11, 2023
08:04 AM
1 Upvote
Shouldn't that be "c:\Program Files\adobe\Adobe Photoshop CC 20XX\Plug-ins\ScriptListener.8li"
... View more
‎Dec 16, 2022
06:22 AM
Photoshop keeps track of the folder you last saved a file to. That's what I'm after.
... View more
‎Dec 16, 2022
05:20 AM
That's a nice work around and an example of answering the question in context. But I asked can you get and/or set the current folder from Photoshop?
... View more
‎Dec 16, 2022
04:28 AM
Sort of pre-empting the users desicions, but not forcing them.
... View more
‎Dec 16, 2022
04:25 AM
Is there a way to get the current folder that is used by Photoshop via scripting? ie if you were to go to the save dialog - what folder would it show? $activePhotoshopFolder That one! (I made that up, BTW) And secondly is possible to change it? If you create a new document then try to assign a path (without saving it) var srcDoc = app.activeDocument;
app.activeDocument.path = sourceFolder;
alert(app.activeDocument.path); Error: 8103: The document has not been saved. Chicken meet Egg. Egg meet Chicken. Why am I doing this? I want to change the folder path without having to pop up a dialog "Do you want to save the file?" at the end script and then saving to the new folder. - Does that make sense?
... View more
‎Dec 14, 2022
03:55 AM
Same problem. Different question. Different angle, different approach. - if that makes sense 😉
... View more
‎Dec 14, 2022
01:49 AM
You can find the name of a font with app.fonts.getByName(myLayer.textItem.font).name; However, if the font is missing it'll throw an error. So we use try/catch displayDialogs = DialogModes.NO; // OFF
var myLayer = app.activeDocument.activeLayer;
var msg = "";
try
{
var myFont = app.fonts.getByName(myLayer.textItem.font).name;
msg += "my font name: " + myFont;
}
catch(eek)
{
var myFont = undefined;
msg += "my font name: " + myFont;
}
alert(msg); Is there another try/catch method I can use to determine if they are either: (A) typekit/Adobe fonts or (B) fonts that have just been uninstalled? Cheers
... View more
‎Dec 11, 2022
08:40 AM
Thanks jazz-y! I was sooooo close 🙂
... View more
‎Dec 07, 2022
12:27 PM
I've wordked out some Action manager code! Go team me! I now have a function that returns the colour of layer - You know you can set them to "red", "violet", "gray" etc. function get_layer_colour_property()
{
var s2t = stringIDToTypeID;
var r = new ActionReference();
var k = "color";
var p = "layer"
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID(p), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var d = executeActionGet(r).getEnumerationValue(stringIDToTypeID(k));
return d;
} So far so good. However, I get back a string - say for violet it's 1449948192. I say string as it corresponds to teh correct colour, doesn't make any sense as a value. Not quite what I was expecting, as I thought it might be the four letter code "Vlt ". So, how do I get the real color layer value (color - DescValueType.ENUMERATEDTYPE)?
... View more
‎Nov 28, 2022
08:50 AM
I'm reading through jazz-y's excellent explanation into action manager code: About halfway down, instead of geting the artboardRect properties I try to look at the layerKind at a bit of text. Only it's not an OBJECTTYPE, but a INTEGERTYPE - so I should be able to loop through it? var q = " - ";
var prop = "layerKind"; // layerKind - DescValueType.INTEGERTYPE
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("integer"), stringIDToTypeID("targetEnum"));
var d = executeActionGet(r).getObjectValue(stringIDToTypeID(prop));
str = prop + " properties\n";
for (var i = 0; i < d.count; i++)
{
str += typeIDToStringID(d.getKey(i)) + q + d.getType(d.getKey(i)) + "\n";
}
alert(str); Only, I get general error 8800 which isn't useful to tell me where I'm going wrong. Any ideas?
... View more
‎Nov 12, 2022
01:53 AM
I sees wheres I gone wrong! 😉 All good now. Thank you.
... View more
‎Nov 11, 2022
01:41 AM
Following your wonderful explanation, Sadly just var s2t = stringIDToTypeID;
var r = new ActionReference();
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
var d = new ActionDescriptor();
var j = executeAction(s2t('convertJSONdescriptor'), d).getString(s2t('json'))
alert(j); results in the existential error: Error 8500: The requested property does not exist. - Yes I realise teh code is not identical -I'm doing an alert, not writing a line.
... View more
‎Nov 10, 2022
11:32 AM
1 Upvote
One way of toggling the layer mask without Action Manager code is to write a state to a text file: Not elegant, but it works. And you don't even need to know what state it was in! // Switch off any dialog boxes
displayDialogs = DialogModes.ERROR; // OFF
var f = "C:\\temp\\layer_mask_state.txt"; // layer mask file
var layerMaskState = read_it(f);
// toggle it!
if (layerMaskState != undefined)
{
layerMaskState = !layerMaskState;
}
else
{
layerMaskState = true;
}
layer_mask(layerMaskState);
// write_it
write_it(layerMaskState, f);
// Switch off any dialog boxes
displayDialogs = DialogModes.ALL; // OFF
function layer_mask(bool)
{
var idsetd = charIDToTypeID( "setd" );
var desc22 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref5 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref5.putEnumerated( idLyr, idOrdn, idTrgt );
desc22.putReference( idnull, ref5 );
var idT = charIDToTypeID( "T " );
var desc23 = new ActionDescriptor();
var idUsrM = charIDToTypeID( "UsrM" );
desc23.putBoolean( idUsrM, bool ); // set here
var idLyr = charIDToTypeID( "Lyr " );
desc22.putObject( idT, idLyr, desc23 );
executeAction( idsetd, desc22, DialogModes.NO );
}
function write_it(astring, afilename)
{
var exportFile = new File(afilename);
exportFile.open("w"); // write destroys
exportFile.writeln(astring);
exportFile.close();
}
function read_it(afilepath)
{
var theFile = new File(afilepath);
// read in file
var words = []; // text array
var textFile = new File(theFile);
textFile.open('r');
while(!textFile.eof)
{
var line = textFile.readln();
if (line != null && line.length >0)
{
words.push(line); // array
}
}
textFile.close();
if (words[0] == "true") return true;
if (words[0] == "false") return false;
return undefined;
}
... View more
‎Nov 10, 2022
08:39 AM
1 Upvote
I have read that post. - It stops just when it was getting good 😉 Also some of us need to learn with examples.
... View more
‎Nov 10, 2022
06:20 AM
As far as I can see these two lines of AM code sets idUsrM to true var idUsrM = charIDToTypeID( "UsrM" );
desc43.putBoolean( idUsrM, true ); My question is how to I get the value of a variable in AM? In a better context this code will enable a layer mask. var idsetd = charIDToTypeID( "setd" );
var desc42 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref12 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref12.putEnumerated( idLyr, idOrdn, idTrgt );
desc42.putReference( idnull, ref12 );
var idT = charIDToTypeID( "T " );
var desc43 = new ActionDescriptor();
var idUsrM = charIDToTypeID( "UsrM" );
desc43.putBoolean( idUsrM, true ); // set to true here
var idLyr = charIDToTypeID( "Lyr " );
desc42.putObject( idT, idLyr, desc43 );
executeAction( idsetd, desc42, DialogModes.NO ); I want to set a variable to the opposite. ie switching it off when on and visa versa. var layerMaskState = !layerMaskCurrentState; Hopefully, that's reasonabaly clear. If not just say so.
... View more
‎Nov 09, 2022
08:33 AM
They don't "dissapear" as such - just default to Myriad Pro or something similar. The script worked a treat 🙂 Also, for my future self: .properties.postscriptName //Post script font names
... View more
‎Nov 09, 2022
07:18 AM
1 Upvote
Niether, I'm trrying to keep track of what typekit fonts I'm currently using. Sometimes the typekits fonts time out - possible from not using them for x days or Creative Cloud is on the blink again. One idea I had, as I'm experiencing Creative Cloud issues, is to keep an array of typekits fonts currently installed. Run a script that automatically creates a document with a string of text of all of those type kit fonts. Repeat on a daily basis so you don't "accidentally" lose access to them. - Just an idea... I've already written a script to find fonts used in a specific document.
... View more
‎Nov 09, 2022
01:09 AM
Well.. that didn't quite get the response I was hoping for. #wasitsomethingIsaid
... View more
‎Nov 03, 2022
07:40 AM
I can determine the number of fonts I have with: var numOfFonts = app.fonts.length; Yay! I have three fonts installed! But I now need a way to determine if that font belong to typekit or not. - This process can be done manually but I'm keen to script this. However, I don't think there are any properties for this in TextItem. Can it be done with scripting?
... View more