Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Retreiving the content created with the Note Tool via Javascript??

New Here ,
Jun 18, 2010 Jun 18, 2010

Hey guys, is it possible to retrieve the text content created with the Note Tool from the tool palette  in a photoshop document via Javascript? Basically, I wanted to store some text inside the Photoshop psd document, and then later on I can use scripting to access the content to be use as variables.

I have search the Javascript scripting reference pdf and the forum here, and I can't find any info the Note Tool. Much appreciated.

TOPICS
Actions and scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Jun 18, 2010 Jun 18, 2010

There is no direct access to notes/annotations.

But you could store your text in the document's metadata.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2010 Jun 23, 2010

Thanks, so when you mention "document's metadata", are you refering to the Document.info property?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 23, 2010 Jun 23, 2010

Yes and if you have a version of Photoshop( CS3 or better ) that supports AdobeXMPScript you can access all the metadata including setting your own custom namespace.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 26, 2010 Jun 26, 2010

Additionally you can use meta-data as a scratch pad area. If done well your scratch pad notes will never be written into a file. I have created some Photoshop Scripts I call run twice scripts to be use within Photoshop Actions these perform sort of a save and restore  functions for actions. These scripts look for their footprint in the documents meta-data to see if it being run for the first or second time. If the first time these add their footprint and save some document state information into meta-data if second they remove footprint and saved state information and restore the document to the saved state.

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2010 Jun 30, 2010

Ok, so I am using the activeDocument.info.keywords property to store my text content. The content is basically a chunk of text that contains some parameters that the user can modify to save out a document. In my script, I am using a variable to store the content from the info.keywords property. But my next hurdle is how can I extract specific part of that variable into other variables, like storing the C:\projects\Textures\ into another variable? I've done some research and got a sense that the "match" method in javascript along with the use of regular expressions might do the job. But I am stuck. Any suggestions?

info.keywords property has the follow chunk of text:

// file path to save 
path(
C:\projects\Textures\)  
// save file format (psd or tga, etc)
format (tga
// include a single alpha channel with the file y/n 
alpha(n
// alpha name - default should be "alpha1" 
alphaName(alpha1
// scale from the original size 
scale(.5
//sharpening
sharpen(.5)

script code:

var saveDoc = activeDocument.info.keywords;

var savePath = saveDoc[0].match(regular expression goes here); // how to grab C:\projects\Textures\ from the saveDoc variable???
alert(savePath);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 30, 2010 Jun 30, 2010

Use either json to store the info as a serialized JS object, or use something simpler like the .ini file format.

json has the advantage that you just have to eval the string to get the object. .ini format has the advantage that it's human readable/editable.

Here's a function I use for convertion .ini strings into simple objects:

function iniFromString(str, ini) {
  var lines = str.split(/\r|\n/);
  var rexp = new RegExp(/([^:]+):(.*)$/);

  if (!ini) {
    ini = {};
  }

  for (var i = 0; i < lines.length; i++) {
    var line = lines.trim();

    // skip empty lines. lines that begin with '#' are comment lines
    if (!line || line.charAt(0) == '#') {
      continue;
    }
    var ar = rexp.exec(line);
    if (!ar) {
      alert("Bad line in config: \"" + line + "\"");
      continue;
      //return undefined;
    }
    ini[ar[1].trim()] = ar[2].trim();
  }

  return ini;
};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 25, 2017 Aug 25, 2017

DOes anyone know if in the newer Photoshop its possible to access or add data for the Note tool?    

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2017 Aug 25, 2017
LATEST

The closest thing is this one by Michael Hale, involving the exportation of the annotation as a raw file via exiftool and a script to read (not write) the content.

view notes from the Notes Tool? - PS-SCRIPTS.COM

Davide

Davide Barranca - PS developer and author
www.ps-scripting.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines